Skip to content

Instantly share code, notes, and snippets.

@Suave
Created May 7, 2009 08:06
Show Gist options
  • Save Suave/107984 to your computer and use it in GitHub Desktop.
Save Suave/107984 to your computer and use it in GitHub Desktop.
js 获取 url 参数
<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