天天看點

前端頁面實作跳轉

onclick跳轉

設定window的location.herf屬性

onclick="window.location.href='URL'"
onclick="location='URL'"
           

調用windows的open方法

onclick=“window.open('URL','_blank')”//在新視窗打開
onclick=“window.open('URL','_self')”//覆寫目前頁
           

a标簽跳轉

<a href="URL" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank">Preface</a> // 在新視窗打開
<a href="URL" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_self">Preface</a> // 覆寫目前頁,target屬性預設為_self可省略
           

js實作頁面跳轉

1.window.location.href方式
window.location.href="URL" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" ;

2.window.navigate方式跳轉
window.navigate("頁面");

3.window.loction.replace方式實作頁面跳轉
window.location.replace("URL");
           

jq頁面跳轉

1.ajax實作頁面跳轉
$.ajax(function(){
type:"POST",
dataType:"json",
url:"/login",//請求頁面
data:"{id=1}",
complete:function(){location.href ="default.aspx"}//跳轉頁面
           

點選事件實作跳轉

$("a logo").click(function(){
    window.location.href="URL" target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow"  target="_blank" rel="external nofollow" ;
});
           

繼續閱讀