js中window.location.search的用法和作用

用该属性获取页面 URL 地址:

window.location 对象所包含的属性

属性 描述
hash 从井号 (#) 开始的 URL(锚)
host 主机名和当前 URL 的端口号
hostname 当前 URL 的主机名
href 完整的 URL
pathname 当前 URL 的路径部分
port 当前 URL 的端口号
protocol 当前 URL 的协议
search 从问号 (?) 开始的 URL(查询部分)


如图就是取出url中的参数。

js 脚本捕获页面 GET 方式请求的参数?其实直接使用 window.location.search 获得,然后通过 split 方法结合循环遍历自由组织数据格式。

大概处理如下:

var searchURL = window.location.search;
searchURL = searchURL.substring(1, searchURL.length);
var targetPageId = searchURL.split("&")[0].split("=")[1];

  

时间: 2024-08-11 09:42:08

js中window.location.search的用法和作用的相关文章

关于js中window.location.href,location.href,parent.location.href,top.location.href的用法

关于js中window.location.href,location.href,parent.location.href,top.location.href的用法 "window.location.href"."location.href"是本页面跳转. "parent.location.href" 是上一层页面跳转. "top.location.href" 是最外层的页面跳转. 举例说明: 如果A,B,C,D都是html,D

关于js中window.location.href,location.href,parent.location.href,top.location.href的使用方法

关于js中"window.location.href"."location.href"."parent.location.href"."top.location.href"的使用方法 "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一层页面跳转 "top.locatio

关于js中"window.location.href"、"location.href" 等如何跳转

关于js中"window.location.href"."location.href"."parent.location.href"."top.location.href"的用法 "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一层页面跳转 "top.location.

关于js中window.location.href,location.href,parent.location.href,top.location.href用法

"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一层页面跳转 "top.location.href"是最外层的页面跳转 举例说明: 如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写 "window.location.href"."locatio

解决js中window.location.href不工作的问题

E6中在html中<a>标识中通过JS添加click事件调用一个JS函数,例如: < script   type = "text/javascript" > function   jump () { window . location . href = 'http://wisejenny.blog.163.com/blog/www.baidu.com' ; } function   enjoy () { return   false ; } < /scri

关于js中&quot;window.location.href&quot;、&quot;location.href&quot;、&quot;parent.location.href&quot;、&quot;top.location.href&quot;的用法(转)

iframe框架的页面跳转             var win = self.parent.document.getElementById('right').contentWindow; win.document.location.href = "VipManage.aspx"; ========================================================================== "window.location.href&

js中window.location.href解决target的问题

location是没办法设置target的.location就是本地本页的意思,只能设置本页的指向,如果界面中用到iframe那么可以这样: parent.frames["iframe的name"].window.loaction.href="a.jsp";

js中window对象详解以及页面跳转

js中window对象详解以及页面跳转 转自:http://www.makaidong.com/%E5%8D%9A%E5%AE%A2%E5%9B%AD%E6%90%9C/39219.shtml 1.window.top.window.location = "index.asp"; 2.window.top.location.href="index.asp" 3. window.top.location.replace("index.asp");

window.location属性用法及解决一个window.location.search为什么为空的问题

通常用window.location该属性获取页面 URL 地址: 1.什么是window.location? 比如URL:http://b.a.com:88/index.php?name=kang&when=2011#first window.location和document.location互相等价的,可以交换使用 location的8个属性都是可读写的,但是只有href与hash的写才有意义. 例如:改变location.href会重新定位到一个URL,而修改location.hash会