让html某一个链接不再新窗口打开

2025-02-27 07:01:36
推荐回答(2个)
回答1:

最简单的在需要新窗口打开的a链接里加上target="_blank"   ,这样方便。


js返回顶部代码:

===js部分=========
$(document).ready(function(){
    //首先将#back-to-top隐藏
    $("#up").hide();
    //当滚动条的位置处于距顶部100像素以下时,跳转链接出现,否则消失
    $(function () {
    $(window).scroll(function(){
    if ($(window).scrollTop()>100){
    $("#up").fadeIn(500);
    }
    else
    {
    $("#up").fadeOut(500);
    }
    });
    //当点击跳转链接后,回到页面顶部位置
    $("#up").click(function(){
    $('body,html').animate({scrollTop:0},100);
    return false;
    });
    });
    });
===Html部分=========
===Css部分=========
#up {
width: 50px;
height: 50px;
margin-left: 508px;
position: fixed;
left: 50%;
bottom: 30px;
z-index: 10000;
cursor: pointer;
background: #1a5daeurl(top_btn.png) no-repeat;
}

回答2:

target="_blank" 改为 target="_self"

相关问答