我有一个如下的网址.
http://localhost/xxx.php?tPath=&pid=37
Run Code Online (Sandbox Code Playgroud)
我想得到pid = 37,但是它的名字是因为按时上面的url就像上面一样,然后当页面刷新时,url就像下面那样.
http://localhost/xxx.php?tPath=&action=xxx&pid=37&value=13&fname=aaaa&fone=4321122
Run Code Online (Sandbox Code Playgroud)
所以我想得到pid = 37.它可能是我将pid作为参数传递的函数,它返回其值.
我该怎么做?
Don*_*sto 13
看看这个或遵循这样的解决方案:
function getParam( 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];
}
var frank_param = getParam( 'pid' );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26724 次 |
| 最近记录: |