Created
June 12, 2015 06:41
-
-
Save foru17/2d1f9f372bfede270ee2 to your computer and use it in GitHub Desktop.
获得URL中的参数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUrlParam(name) { | |
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 | |
var r = window.location.search.substr(1).match(reg); //匹配目标参数 | |
if (r != null) return unescape(r[2]); | |
return null; //返回参数值 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment