<Script language="javascript"> function getRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; } </script> <script> $(function () { var getParams = getRequest(); }) </script>
书写在HTML界面或者jsp界面中
其他参数获取介绍:
1、设置或获取对象指定的文件名或路径。
window.location.pathname
2、设置或获取整个 URL 为字符串。
window.location.href
3、设置或获取与 URL 关联的端口号码。
window.location.port
4、设置或获取 URL 的协议部分。
window.location.protocol
5、设置或获取 href 属性中在井号“#”后面的分段。
window.location.hash
6、设置或获取 href 属性中跟在问号后面的部分。
window.location.search
window.location.host