A <script> Urlinfo=window.location.href; Gets the URL of the current page len=urlinfo.length;//gets the length of the URL Offset=urlinfo.indexof ("?"); /sets the position at which the parameter string starts NEWSIDINFO=URLINFO.SUBSTR (Offset,len)//Fetch parameter string This will get a string like "id=1" Newsids=newsidinfo.split ("=");//To split the obtained argument string by "=" newsid=newsids[1];//get the parameter value Alert ("The parameter value you want to pass is" +newsid); </script> Two A better way: Declare a querystring function <script type= "Text/javascript" > Request = { Querystring:function (item) { var svalue = Location.search.match (New RegExp ("[/?/&]" + Item + "= ([^/&]*) (/&?)", "I")); Return svalue? SVALUE[1]: svalue; } } </script> When used like Java call on the line: <script type= "Text/javascript" > document.write (Request.QueryString ("name")); </script> |
Turn from: http://hi.baidu.com/yizusong/blog/item/8f8c042e5c505f554fc226a8.html