Common common method

1. Get the name of the parameter values ​​of the parameters carried in the url

/ ** 
 * Get the url parameter 
 * / 
function getUrlParam (name) { 
    var new new REG = the RegExp ( "(^ | &)" + name + "= ([^ &] *) (& | $)"); // constructor regular expression object containing a target parameter 
    var r = window.location.search.substr (1) .match (reg); // matches the target parameter 
    if (! r = null) return unescape (r [2] ); return null; // the return value 
}

用法:url :http://localhost:8003/htmls/xxxxxxxx.html?guid=b3905077-ac9a-b9ba-5ba0-8ad411fa7d69&iType=2

Then, type var = getUrlParam ( "type in");

console.log (type in)

Guess you like

Origin www.cnblogs.com/liangpi/p/10981125.html