url传参及windows.location相关属性说明
2014-08-15 16:23
260 查看
本节分享的这段jquery代码,用于获取当前页面url传递的参数。
代码如下:
view source
print?
调用此request即可,例如调用request("ID")。
附,windows.location相关属性及说明。
设置或获取对象指定的文件名或路径。
window.location.pathname
原文地址:http://www.jbxue.com/article/11659.html
设置或获取整个 URL 为字符串。
window.location.href
设置或获取与 URL 关联的端口号码。
window.location.port
设置或获取 URL 的协议部分。
window.location.protocol
设置或获取 href 属性中在井号“#”后面的分段。
window.location.hash
设置或获取 location 或 URL 的 hostname 和 port 号码。
window.location.host
设置或获取 href 属性中跟在问号后面的部分。
window.location.search
window.location 属性 描述
hash 设置或获取
href 属性中在井号“#”后面的分段。
host 设置或获取 location 或 URL 的 hostname 和 port 号码。
hostname 设置或获取 location 或 URL 的主机名称部分。
href 设置或获取整个 URL 为字符串。
pathname 设置或获取对象指定的文件名或路径。
port 设置或获取与
URL 关联的端口号码。
protocol 设置或获取 URL 的协议部分。
search 设置或获取 href 属性中跟在问号后面的部分。
代码如下:
view source
print?
01 | /*--获取网页传递的参数--*/ |
02 | function request(paras) |
03 | { |
04 | var url = location.href; |
05 | var paraString = url.substring(url.indexOf( "?" )+1,url.length).split( "&" ); |
06 | var paraObj = {} |
07 | for (i=0;j=paraString[i];i++){ |
08 | paraObj[j.substring(0,j.indexOf( "=" )).toLowerCase()] = j.substring(j.indexOf( "=" )+1,j.length); |
09 | } |
10 | var returnValue = paraObj[paras.toLowerCase()]; |
11 | if ( typeof (returnValue)== "undefined" ){ |
12 | return "" ; |
13 | } else { |
14 | return returnValue; |
15 | } |
16 | } |
附,windows.location相关属性及说明。
设置或获取对象指定的文件名或路径。
window.location.pathname
原文地址:http://www.jbxue.com/article/11659.html
设置或获取整个 URL 为字符串。
window.location.href
设置或获取与 URL 关联的端口号码。
window.location.port
设置或获取 URL 的协议部分。
window.location.protocol
设置或获取 href 属性中在井号“#”后面的分段。
window.location.hash
设置或获取 location 或 URL 的 hostname 和 port 号码。
window.location.host
设置或获取 href 属性中跟在问号后面的部分。
window.location.search
window.location 属性 描述
hash 设置或获取
href 属性中在井号“#”后面的分段。
host 设置或获取 location 或 URL 的 hostname 和 port 号码。
hostname 设置或获取 location 或 URL 的主机名称部分。
href 设置或获取整个 URL 为字符串。
pathname 设置或获取对象指定的文件名或路径。
port 设置或获取与
URL 关联的端口号码。
protocol 设置或获取 URL 的协议部分。
search 设置或获取 href 属性中跟在问号后面的部分。
相关文章推荐
- WINDOWS系统属性符号说明
- window.location.hash 属性使用说明
- Windows下 Apache2.2 + PHP + phpMyAdmin + MySQL 配置简要相关说明
- JS document.URL , windows.location.href 的区别
- View类的XML属性、相关方法及说明
- Asp.net 2.0 中如何调用用户控件(UserControl)的相关方法或属性/如何传参等
- 关于nginx根据url进行负载分配即location部分的相关设置
- view类的XML属性、相关方法和说明
- 如何查看nginx运行状态及相关属性说明
- hbase 的shell操作中相关属性说明
- FLASH播放器控件相关属性和方法说明.
- Request.Url相关属性
- WINDOWS系统属性符号说明
- 在基于 Windows 的计算机中的设备管理器生成的代码 10 相关的错误的说明
- android android:windowSoftInputMode相关属性
- Request Url相关属性
- WINDOWS系统属性符号说明
- android:ListView相关属性说明
- 如何查看nginx运行状态及相关属性说明
- view类的xml属性、相关方法及说明