获取URL查询字符串参数的Javascript函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取URL查询字符串参数的Javascript函数相关的知识,希望对你有一定的参考价值。
Here is a small function [[lobo235](http://www.netlobo.com/javascript_tooltips.html "Javascript Tool-tips")] wrote that will parse the window.location.href value and return the value for the parameter you specify. It does this using javascript's built in regular expressions.
function gup( name ) { name = name.replace(/[[]/,"\[").replace(/[]]/,"\]"); var regexS = "[\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; }
以上是关于获取URL查询字符串参数的Javascript函数的主要内容,如果未能解决你的问题,请参考以下文章
使用jQuery / Javascript(查询字符串)获取查询字符串参数url值