开发者

How to send data using GET to Java Script

开发者 https://www.devze.com 2022-12-15 14:34 出处:网络
I wan\'t to know How to send data using GET to Java Script like from link: C:/folder/test.html?x=1 <script>

I wan't to know How to send data using GET to Java Script like from

link: C:/folder/test.html?x=1

<script>
//when page accessed
//access x data sent in from the link
</script>

Note, this is for cli开发者_开发技巧ent page not server!


Is this what you are looking for?


You need to parse location.search. A simple implementation would be:

var matches = null;
var params = {}, raw_params = location.search.substring(1).split('&');
for (i in raw_params)
{
    matches = raw_params[i].match (/^([^=]+)=(.+)$/);
    if (matches) params[matches[1]] = matches[2];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消