Created
May 7, 2009 08:06
-
-
Save Suave/107984 to your computer and use it in GitHub Desktop.
js 获取 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
<script type="text/javascript"> | |
<!-- | |
function getQueryStringRegExp(name) | |
{ | |
var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i"); | |
if (reg.test(location.href)) return unescape(RegExp.$2.replace(/\+/g, " ")); return ""; | |
}; | |
//http://localhost/test.html?aa=bb&test=cc+dd&ee=ff | |
alert(getQueryStringRegExp('test')); | |
//--> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment