<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      HTML頁面跳轉及參數傳遞問題

      [摘要]這篇文章給大家詳細介紹了HTML頁面跳轉及參數傳遞問題,希望能幫助到大家。HTML頁面跳轉:window.open(url, "", "width=600,height=400");第二個參數:_self,在當前窗口打開窗口;_blank(默認值),在另外的...
      這篇文章給大家詳細介紹了HTML頁面跳轉及參數傳遞問題,希望能幫助到大家。

      HTML頁面跳轉:

      window.open(url, "", "width=600,height=400");

      第二個參數:_self,在當前窗口打開窗口;_blank(默認值),在另外的新建窗口打開新窗口;

      window.location.href="http://www.jb51.net";     //在同當前窗口中打開窗口
      window.history.back(-1);    //返回上一頁面
       <a href="http://www.baidu.net"  target="_blank">

      HTML參數傳遞:

      1. url傳參:

      第一個頁面(a.html):

      var obj = a.value; //傳給彈出頁面參數
      var url = 'jxb.html?obj='+obj;
      url = encodeURI(url);
      window.open(url, "", "width=600,height=400");

      第二個頁面(b.html):

      var url = decodeURI(window.location.href);
      var argsIndex = url .split("?obj=");
      var arg = argsIndex[1];

      注:中文傳輸:可以在頁面a用encodeURI 編碼url 在b頁面用decodeURI解碼url

      2. cookie傳參:

      function setCookie(cname,cvalue){
          document.cookie = cname + "=" + cvalue;
      }
      function getCookie(cname){
          var name = cname + "=";
          var ca = document.cookie;
      }

      3. localStorage對象傳參:

      a.html:

      var p = doucment.getElementById('要獲取字符串的p ID名');
      localStorage.string = p.textContent;

      b.html:

      var p = doucment.getElementById('要寫入的p ID名');
      p.textContent = localStorage.string;

      4. window.opener()

      父頁面:

      <input type="text" name="textfield" id="textfield"/>

      window.open("子頁面.html");

      子頁面:

      window.opener.document.getElementByIdx('textfield').value='123123123';

      總結

      以上內容就是HTML頁面跳轉及參數傳遞問題,希望能幫助到大家。

      相關推薦:

      Javascript頁面跳轉間的常用方法有哪些

      Web頁面跳轉并取值的方法指導

      關于html頁面跳轉的7篇文章推薦

      以上就是HTML頁面跳轉及參數傳遞問題的詳細內容,更多請關注php中文網其它相關文章!


      網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。




      日韩精品一区二区三区高清