/* * * get Address bar parameter * * @example geturlstring (' id ') * * * @desc call with judgment, guarantee the program will not go wrong * var myurl = geturlstring (' id '); * if (Myurl! = null && myurl.tostring (). length > 1) {* Alert (geturlstring ("id")); *} * * @param string param to get the parameter name in the Address bar * @return String Value * @type String * * @name geturlstring () * * @author iceman/[email protected] */ function Geturlstring (param) { var svalue = Location.search.match (new RegExp ("[\?\&]" + M + "= ([^\&]*] (\&?)", " I " return svalue? decodeURI (Svalue[1
Call the time unified to do such a judgment, to avoid you do not pass arguments, such as your address is abc.html back no parameters, the force output call results sometimes error
function () { var myurl = getparm ("id"); if null && myurl.tostring (). length > 1) { alert (Getparm ("id"));} }
This will not be an error!
Note: ECMAScript v3 has removed the unescape () function from the standard and opposes its use, so it should be replaced with decodeURI () and decodeURIComponent ().
Ways to get Address bar parameters using JavaScript