js和jq跳轉到另一個頁面或者在另一個窗口打開頁面



$("#pic").click(function(){ location.href='newpage.html'; });

上面的相當於<a href="newpage.html" target="_self"><img src="img.jpg" /></a>

$("#pic").click(function(){
    window.open('newpage.html');
});

相當於<a href="newpage.html" target="_blank"><img src="img.jpg" /></a>

我們可以利用http的重定向來跳轉

window.location.replace("http//www.jb51.net");

使用href來跳轉

window.location.href = "http//www.jb51.net";

使用jQuery的屬性替換方法

$(location).attr('href', 'http://www.jb51.net');
$(window).attr('location','http://www.jb51.net');
$(location).prop('href', 'http//www.jb51.net')

使用jQuery的屬性替換方法結束

 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM