window.location.search作用

window.location.search.substr(1).split("&") 这里面的相关属性和时间还有参数能具体说明一下吗?
window.location 
window的location对象

search 
得到的是url中query部分

substr() 
返回一个从指定位置开始的指定长度的子字符串 
这里设置为1,是为了把url中的?号去掉

split() 
将一个字符串分割为子字符串,然后将结果作为字符串数组返回 
这里就是把query部分以&为分割符,分割

测试:把下面代码保存为1.htm 
注意是1.htm 
<script language="javascript"> 
alert(window.location.search.substr(1).split("&")) 
</script>

下面的是本页面
<a href="1.htm?topic=1&id=2">测试</a>

window.location.search作用

时间: 2024-08-07 15:06:57

window.location.search作用的相关文章

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

作用:取得[http://111111?A=1&B=2&C=3....]红色部分 上代码,起个名字:123.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta charset="utf-8"

为什么 window.location.search 为空?

1,什么是window.location?示例 URL:http://b.a.com:88/index.php?name=kang&when=2011#first 属性 含义 值 protocol: 协议 "http:" hostname: 服务器的名字 "b.a.com" port: 端口 "88" pathname: URL中主机名后的部分 "/index.php" search: "?"后的部

(转)window.location.search的用法

location.search是从当前URL的?号开始的字符串如:http://www.51js.com/viewthread.php?tid=22720它的search就是?tid=22720 通过这个函数就可以轻易取到连接后面带的参数,这个可用户父窗口向子窗口传递参数eg:Java代码: function openTable(id){    var feathers="status=no,width=650px,height=670px,top=0px,menubar=no,resizabl

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会

window.location地址对应的方法

window.location方法获取URL 统一资源定位符 (Uniform Resource Locator, URL) 完整的URL由这几个部分构成: scheme://host:port/path?query#fragment scheme:通信协议 常用的http,ftp,maito等 host:主机 服务器(计算机)域名系统 (DNS) 主机名或 IP 地址. port:端口号 整数,可选,省略时使用方案的默认端口,如http的默认端口为80. path:路径 由零或多个"/&quo

window.location.href问题,点击,跳转到首页

onClick="window.location.href='./';" 点击,跳转到首页. location.href=url Js中实现跳转 window.location.href跳转新窗口 window.location.href="http://cwhois.cnnic.cn/validatecode/validate.jsp?value="+strName+"&entity=domain&service=/whois&i

location.search 详解

JS中location.search什么意思 设置或获取网页地址跟在问号后面的部分 当以get方式在url中传递了请求参数时,可以利用location的search属性提取参数的值,下面的代码把参数的名称和对应的值存储在2个数组中. <script>function test(){var url=window.location.search;if(url.indexOf("?")!=-1) {    var str = url.substr(1)     strs = st

[转]window.location方法获取URL及window.location.assign(url)和replace(url)区别

本文转自:http://blog.csdn.net/chendi1985/article/details/5291773 window.location方法获取URL 统一资源定位符 (Uniform Resource Locator, URL) 完整的URL由这几个部分构成: scheme://host:port/path?query#fragment scheme:通信协议 常用的http,ftp,maito等 host:主机 服务器(计算机)域名系统 (DNS) 主机名或 IP 地址. p