久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      詳解js獲取url參數(shù)值的方法

      詳解js獲取url參數(shù)值的方法

      js獲取url參數(shù)值的方法

      Location 對象是 Window 對象的一個(gè)部分,可通過 window.location 屬性來訪問。

      hash:設(shè)置或返回從井號 (#) 開始的 URL(錨)。

      host:設(shè)置或返回主機(jī)名和當(dāng)前 URL 的端口號。

      hostname:設(shè)置或返回當(dāng)前 URL 的主機(jī)名。

      href:設(shè)置或返回完整的 URL。

      pathname:設(shè)置或返回當(dāng)前 URL 的路徑部分。

      port:設(shè)置或返回當(dāng)前 URL 的端口號。

      protocol:設(shè)置或返回當(dāng)前 URL 的協(xié)議。

      search:設(shè)置或返回從問號 (?) 開始的 URL(查詢部分)。

      js獲取url參數(shù)值的方式

      一個(gè)參數(shù):

      var test =window.location.href; var 參數(shù)=test.split("?參數(shù)=")[1];

      多個(gè)參數(shù):

      方式一:

      function GetQueryString(name) {    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");    var r = window.location.search.substr(1).match(reg); //獲取url中"?"符后的字符串并正則匹配   var context = "";    if (r != null)       context = r[2];    reg = null;    r = null;    return context == null || context == "" || context == "undefined" ? "" : context;  }

      調(diào)用方法:

      var 參數(shù)1 = GetQueryString['參數(shù)1']; var 參數(shù)2 = GetQueryString['參數(shù)2']; var 參數(shù)3 = GetQueryString['參數(shù)3'];

      方式二:

      function GetRequest() { var url = location.search; //獲取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; }

      調(diào)用方法:

      var Request = new Object(); Request = GetRequest(); var 參數(shù)1,參數(shù)2,參數(shù)3,參數(shù)N; 參數(shù)1 = Request['參數(shù)1']; 參數(shù)2 = Request['參數(shù)2']; 參數(shù)3 = Request['參數(shù)3']; 參數(shù)N = Request['參數(shù)N'];

      推薦教程:《JS》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號