最简单的在需要新窗口打开的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;
}
target="_blank" 改为 target="_self"