本文目錄一覽:
- 1、什麼JS跳轉?
- 2、JS代碼怎麼跳轉到另一個頁面呢
- 3、如何使用JavaScript實現 按鈕跳轉頁面功能?
- 4、如何用js跟蹤頁面的跳轉
- 5、html網頁跳轉javascript代碼實現
- 6、js如何根據系統時間指定跳轉,麻煩寫代碼!謝謝
什麼JS跳轉?
js可以輕鬆的實現網頁的跳轉,平時我們在訪問某一網站時卻被跳轉到了另一個網站上,這其中的跳轉方法可以有很多種,現在給大家分享一下js實現頁面跳轉的方法。
一、js直接跳轉。實現代碼如下:
script type=”text/javascript”
window.location.href = ‘網址’;
/script
也可用self.location=’網址’;
二、頁面停留指定時間再跳轉,如3秒:
script type=”text/javascript”
function jumurl(){
window.location.href = ‘網址’;
}
setTimeout(jumurl,3000);
/script
三、頁面跳出框架
script type=”text/javascript”
top.location.href=’網址’;
/script
四、返回上一頁
script type=”text/javascript”
window.history.back(-1);
/script
JS代碼怎麼跳轉到另一個頁面呢
script language=”javascript” function IsIndex() { var strSession = ”.toString(); if( strSession == “”) { alert(‘請登陸’); location.href = ‘你要登錄的頁面的文件名’; return false; } } /script
如何使用JavaScript實現 按鈕跳轉頁面功能?
javascript中的location.href有很多種用法,主要如下:
self.location.href=”/url” 當前頁面打開URL頁面
location.href=”/url” 當前頁面打開URL頁面
windows.location.href=”/url” 當前頁面打開URL頁面,前面三個用法相同
this.location.href=”/url” 當前頁面打開URL頁面
parent.location.href=”/url” 在父頁面打開新頁面
top.location.href=”/url” 在頂層頁面打開新頁面
如何用js跟蹤頁面的跳轉
常規的JS頁面跳轉代碼
1、在原來的窗體中直接跳轉用
script type=”text/javascript”
window.location.href=”你所要跳轉的頁面”;
/script
2、在新窗體中打開頁面用:
script type=”text/javascript”
window.open(‘你所要跳轉的頁面’);
/script
3、JS頁面跳轉參數的註解
SCRIPT LANGUAGE=”javascript”
!–
window.open (‘page.html’, ‘newwindow’, ‘height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no’)
//寫成一行
—
/SCRIPT
參數解釋:
SCRIPT LANGUAGE=”javascript” js腳本開始;
window.open 彈出新窗口的命令;
‘page.html’ 彈出窗口的文件名;
‘newwindow’ 彈出窗口的名字(不是文件名),非必須,可用空’代替;
height=100 窗口高度;
width=500 窗口寬度;
top=0 窗口距離屏幕上方的象素值;
left=0 窗口距離屏幕左側的象素值。
html網頁跳轉javascript代碼實現
代碼如下:
html
head
title page A /title
script type=”text/javascript”
function delyLoad(){
setTimeout(function(){
window.location.href=’b.html’;
},5000)
}
/script
/head
body onload=”delyLoad()”
h1A/h1
/body
/html
首先做一個計時器,記時5秒。5秒後將location的鏈接轉為b.html。如果b.html與a不在同一個頁面下,最好寫絕對路徑
js如何根據系統時間指定跳轉,麻煩寫代碼!謝謝
script
var h=new Date().getHours();
if(h7h20)location.href=”A頁面url”;
else location.href=”B頁面url”;
/script
原創文章,作者:VFEPM,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/331365.html