HTML5 參數傳遞,html5參數傳遞

來源:互聯網
上載者:User

HTML5 參數傳遞,html5參數傳遞

頁面顯示效果,如:

首頁面代碼:

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title></title>    </head>    <body>          <br>          <br>        <a href="jssendValue.html?id=test&user=xujinzhong&pwd=123456&uid=123456" target="_blank"&nbsp >>>> 點擊跳轉到下一個介面 >>></a>     </body></html>

跳轉頁面代碼:

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title></title>        <script language="javascript">            var myID = "id"            var myuser = "user"            var mypwd = "pwd"            var myuid = "uid"            function getParameter(param) {                var query = window.location.search; //擷取URL地址中?後的所有字元                  var iLen = param.length; //擷取你的參數名稱長度                  var iStart = query.indexOf(param); //擷取你該參數名稱的其實索引                  if(iStart == -1) //-1為沒有該參數                      return "";                iStart += iLen + 1;                var iEnd = query.indexOf("&", iStart); //擷取第二個參數的其實索引                  if(iEnd == -1) //只有一個參數                      return query.substring(iStart); //擷取單個參數的參數值                  return query.substring(iStart, iEnd); //擷取第二個參數的值              }            function init() {                document.getElementById("id").value = getParameter(myID);                document.getElementById("user").value = getParameter(myuser);                document.getElementById("pwd").value = getParameter(mypwd);                document.getElementById("uid").value = getParameter(myuid);            }        </script>    </head>    <body onload="init()">        this is a test <br>        <input id="id" type="text" />        <br>        <input id="user" type="text" />        <br>        <input id="pwd" type="text" />        <br>        <input id="uid" type="text" />    </body></html>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.