如何在窗口加载中使用jquery在html页面中获取查询sting值? [英] How to get query sting value in html page using jquery in window load ?
本文介绍了如何在窗口加载中使用jquery在html页面中获取查询sting值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi
如何在html页面中打开jquery中的查询字符串值,
注意:不需要服务器端代码,需要在客户端使用document.ready函数在html页面中的代码。
i会通过查询sting这样的Welcome.html?用户名= aaaa
问候
Aravind
Hi
How to get query string value in jquery in html page open,
Note: no need in server side code,need in client side code in html page using document.ready function.
i will pass query sting like this Welcome.html?Username=aaaa
Regards
Aravind
推荐答案
你不需要为此目的使用jQuery。您只能使用一些纯JavaScript:
You don't need jQuery for that purpose. You can use just some pure JavaScript:
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
var prodId = getParameterByName('prodId');
这篇关于如何在窗口加载中使用jquery在html页面中获取查询sting值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文