window.location 属性】的更多相关文章

转载:http://www.5icool.org/a/201105/a564.html 如果你稍微懂一些JS代码,一般都会知道 window.location.href 这个属性.并且用该属性获取页面 URL 地址: window.location.href = window.location.href; 好吧,我告诉你,这样弱掉了.其实原生 JavaScript 真是什么都有. window.location 对象所包含的属性 属性 描述 hash 从井号 (#) 开始的 URL(锚) hos…
通常用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会…
属性 含义 值 protocol: 协议 "http:" hostname: 服务器的名字 "b.a.com" port: 端口 "88" pathname: URL中主机名后的部分 "/index.php" search: "?"后的部分,又称为查询字符串 "?name=kang&when=2011" hash: 返回"#"之后的内容 "#firs…
1.location 对象 // 假设当前url是 http://localhost/rpc/plugin.php#hash?a=aaa&b=bbb alert(window.location.hash);// #hash alert(window.location.hostname);// localhost alert(window.location.pathname);// /rpc/plugin.php alert(window.location.protocol);// http: a…
window.location属性 描述 hash 设置或获取 href 属性中在井号“#”后面的分段. host 设置或获取 location 或 URL 的 hostname 和 port 号码. hostname 设置或获取 location 或 URL 的主机名称部分. href 设置或获取整个 URL 为字符串. pathname 设置或获取对象指定的文件名或路径. port 设置或获取与 URL 关联的端口号码. protocol 设置或获取 URL 的协议部分. search 设置…
window.location 对象所包含的属性 属性 描述 hash 从井号 (#) 开始的 URL(锚) host 主机名和当前 URL 的端口号 hostname 当前 URL 的主机名 href 完整的 URL pathname 当前 URL 的路径部分 port 当前 URL 的端口号 protocol 当前 URL 的协议 search 从问号 (?) 开始的 URL(查询部分) window.location.hash 要使用 JS 定位锚点,完全可以使用 window.hash…
示例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: "?"后的部分,又称为查询字符串 "?name…
window.location各属性的值 window.location.href            "https://i.cnblogs.com/EditPosts.aspx?opt=1" window.location.protocol      "https:" window.location.host           "i.cnblogs.com" window.location.port            返回端口号 win…
属性 说明 window.location.href 完整的url window.location.protocol 协议 window.location.hostname 主机名 window.location.host 主机名+端口号 window.location.port 端口号 window.location.pathname 当前URL的路径部分 var href  =  window.location.href;//完整的urlvar protocol  =  window.loc…
Location对象 location用于获取或设置窗体的URL,并且可以用于解析URL. 语法: location.[属性|方法] location对象属性图示: location 对象属性: location 对象方法: 任务 在右边编辑器script标签内,获取当前显示文档的URL,并输出. <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content=&quo…