且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在javascript中获取查询字符串值

更新时间:2023-02-24 11:40:02

(文件).ready。



任何建议。 .....



谢谢
(document).ready.

Any Suggestion......

Thanks


unction getQuerystring(key)

{



 key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,\\\]);

 var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");

 var qs = regex.exec(window.location.href);

 if(qs == null)

alert("SOme message");

else alert(qs[1]);

}


Hey Dude ..



你可以得到&安培;使用以下行在JavaScript中提取查询字符串。







Hey Dude..

You can get & extract the query string in JavaScript using the following Lines.



var qrStr = window.location.search;
    qrStr = qrStr.split("?")[1].split("=")[1];







希望这个

将有助于...:)




Hope this
will help...:)