亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript實現(xiàn)頁面跳轉(zhuǎn)的5種方法總結

 更新時間:2023年12月19日 11:01:24   作者:天香自然,地上紅豆  
在前臺開發(fā)中會涉及頁面跳轉(zhuǎn)的問題,下面這篇文章主要給大家總結介紹了關于JavaScript實現(xiàn)頁面跳轉(zhuǎn)的5種方法,文中通過代碼介紹的非常詳細,需要的朋友可以參考下

我總結了這五種方法:

第一種:使用JS跳轉(zhuǎn)頁面

(1)跳轉(zhuǎn)帶參

<script language="javascript" type="text/javascript">
        window.location.href="jingxuan.do?backurl=" rel="external nofollow"  + window.location.href; 
 </script>

(2)跳轉(zhuǎn)無參

<script>window.location.;</script>

第二種:返回上一次預覽界面

<script language="javascript">
   alert("返回");
   window.history.back(-1);
 </script>

HTML頁面嵌套

<a href="javascript:history.go(-1)" rel="external nofollow" >返回上一步</a>
 <a href="<%=Request.ServerVariables(" rel="external nofollow" HTTP_REFERER")%>">返回上一步</a>

第三種:button按鈕添加事件跳轉(zhuǎn)

<input name="前端知音" type="button" value="前端知音" onClick="location.href='login.do'">

第四種:在新窗口打開

<a href="javascript:" rel="external nofollow"  onClick="window.open('login.do','','height=500,width=611,scrollbars=yes,status=yes')">新窗口</a>

第五種:通過meta設置跳轉(zhuǎn)頁面

<head>
     <!--只刷新不跳轉(zhuǎn) -->
     <meta http-equiv="refresh" content="5">
     <!--定時跳轉(zhuǎn) -->
     <meta http-equiv="refresh" content="5;url=index.html"> 
 </head>

這里還有一個頁面?zhèn)髦?/p>

第一個頁面

<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>無標題文檔</title>
 </head>
 <SCRIPT LANGUAGE="JavaScript">
     function test(){
         var s = document.getElementById("txt");
         location.href="test2.html?" rel="external nofollow" +"txt="+encodeURI(s.value);
     }
 </SCRIPT>
 <body>
  
 <input type="text" id="txt">
 </br>
 <input type="button" value="TEST" onclick="test()"/>
  
 </body>
 </html>

第二個頁面

<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>無標題文檔</title>
 </head>
  
 <body>
   <script language="javascript" type="text/javascript">
   var loc = location.href;
   var n1 = loc.length;//地址的總長度
   var n2 = loc.indexOf("=");//取得=號的位置
   var id = decodeURI(loc.substr(n2+1, n1-n2));//從=號后面的內(nèi)容
   alert(id);
   //document.write(id)
   </script>
 </body>
 </html>

總結 

到此這篇關于JavaScript實現(xiàn)頁面跳轉(zhuǎn)的5種方法總結的文章就介紹到這了,更多相關JS頁面跳轉(zhuǎn)方法內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論