這9個常用的js跳轉代碼,你用過幾個?

今天整理下我們常用的js跳轉代碼,常用的js跳轉代碼比如:js倒計時跳轉代碼、pc站跳轉手機站代碼、在原來的窗體中直接js跳轉用、在新窗體中打開頁面用、js直接跳轉代碼、js返回代碼、head標籤內加如下代碼實現頁面定時自動跳轉代碼、self.location方式實現頁面跳轉、top.location方式實現頁面跳轉,具體請看以下代碼,希望對你有幫助。

js跳轉代碼

1.js倒計時跳轉代碼

window.location.href="你所要跳轉的頁面";

3.在新窗體中打開頁面用:

window.open('http://www.7dadi.com/');

4.js直接跳轉代碼

location.href="http://www.7dadi.com/";

5.js返回代碼

7.self.location方式實現頁面跳轉

self.location='http://www.7dadi.com';

8.top.location方式實現頁面跳轉

top.location='http://www.7dadi.com';

9.pc站跳轉手機站代碼

var mobileAgent = new Array("iphone", "ipod", "ipad", "android",

"mobile", "blackberry", "webos", "incognito", "webmate",

"bada", "nokia", "lg", "ucweb", "skyfire");

var browser = navigator.userAgent.toLowerCase();

var isMobile = false;

for(var i=0; i<mobileagent.length>

if(browser.indexOf(mobileAgent[i])!=-1){

isMobile = true;

url = window.location.href;

str=url.replace('www.','wap.');

window.location.href=str;

break;

}

}

/<mobileagent.length>

原文地址:http://tangjiusheng.com/js/124.html