我總結(jié)了這五種方法:
第一種:使用JS跳轉(zhuǎn)頁(yè)面
(1)跳轉(zhuǎn)帶參
<script language="javascript" type="text/javascript">
window.location.href="jingxuan.do?backurl=" + window.location.href;
</script>
(2)跳轉(zhuǎn)無(wú)參
<script>window.location.;</script>
第二種:返回上一次預(yù)覽界面
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
HTML頁(yè)面嵌套
<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>
第三種:button按鈕添加事件跳轉(zhuǎn)
<input name="前端知音" type="button" value="前端知音" onClick="location.href='login.do'">
?第四種:在新窗口打開(kāi)
<a href="javascript:" onClick="window.open('login.do','','height=500,width=611,scrollbars=yes,status=yes')">新窗口</a>
第五種:通過(guò)meta設(shè)置跳轉(zhuǎn)頁(yè)面文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-789064.html
<head>
<!--只刷新不跳轉(zhuǎn) -->
<meta http-equiv="refresh" content="5">
<!--定時(shí)跳轉(zhuǎn) -->
<meta http-equiv="refresh" content="5;url=index.html">
</head>
這里還有一個(gè)頁(yè)面?zhèn)髦?span toymoban-style="hidden">文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-789064.html
第一個(gè)頁(yè)面
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
function test(){
var s = document.getElementById("txt");
location.href="test2.html?"+"txt="+encodeURI(s.value);
}
</SCRIPT>
<body>
<input type="text" id="txt">
</br>
<input type="button" value="TEST" onclick="test()"/>
</body>
</html>
第二個(gè)頁(yè)面
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
</head>
<body>
<script language="javascript" type="text/javascript">
var loc = location.href;
var n1 = loc.length;//地址的總長(zhǎng)度
var n2 = loc.indexOf("=");//取得=號(hào)的位置
var id = decodeURI(loc.substr(n2+1, n1-n2));//從=號(hào)后面的內(nèi)容
alert(id);
//document.write(id)
</script>
</body>
</html>
到了這里,關(guān)于JS 實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)的幾種方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!