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

做的一个导航,设置了
<base target="_blank" />
然后
<a href="#top">TOP</a>
加那个代码使它不在新窗口打开

或者用别的方法实现top
直接地址的手机导航,如果那样的话会增加页面大小,链接还蛮多的。

最简单的在需要新窗口打开的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部分=========
<div id="up" style="display:none;"></div>

===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;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-12-25
target="_blank" 改为 target="_self"
相似回答