js获取url协议、url, 端口号等信息路由信息

alert("location:"+window.location);

alert("href: "+window.location.href);

alert("protocol: "+window.location.protocol);

alert("host&port: "+window.location.host);

alert("port: "+window.location.port);

alert("hostname: "+window.location.hostname);

原文地址:https://www.cnblogs.com/xuange306/p/9343174.html

时间: 2024-08-30 15:36:10

js获取url协议、url, 端口号等信息路由信息的相关文章

js获取当前页面url网址等信息

使用js获取当前页面的url网址信息. 1.设置或获取整个 URL 为字符串: window.location.href 2.设置或获取与 URL 关联的端口号码: window.location.port 3.设置或获取 URL 的协议部分 window.location.protocol 4.(www.jbxue.com)设置或获取 href 属性中跟在问号后面的部分 window.location.search 5.获取变量的值(截取等号后面的部分) var url = window.lo

js获取网页可见区域、屏幕分辨率高度等信息

js获取网页的各种高度,例如可见区域.正文以及屏幕分辨率的高度的方法.有关document的一些属性:网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: document.body.offsetWidth (包括边线的宽) 网页可见区域高: document.body.offsetHeight (包括边线的高) 网页正文全文宽: document.body.scrollWidth 网页正文

js获取当前页面的url网址信息小汇总

在WEB开发中,时常会用到javascript来获取当前页面的url网址信息,在这里是我的一些获取url信息的小总结. 下面我们举例一个URL,然后获得它的各个组成部分:http://i.cnblogs.com/EditPosts.aspx?opt=1 1.window.location.href(设置或获取整个 URL 为字符串) var test = window.location.href; alert(test); 返回:http://i.cnblogs.com/EditPosts.as

用js获取当前页面的url的相关信息方法

1. 当前页面的完整url获取方式: window.localtion.url; 2. pathname部分: window.location.pathname 3. 设置或获取对象指定的文件名或路径. alert(window.location.pathname) 设置或获取整个 URL 为字符串. alert(window.location.href); 设置或获取与 URL 关联的端口号码. alert(window.location.port) 设置或获取 URL 的协议部分. aler

js获取当前页面的URL信息

window.location属性 描述 hash 设置或获取 href 属性中在井号"#"后面的分段. host 设置或获取 location 或 URL 的 hostname 和 port 号码. hostname 设置或获取 location 或 URL 的主机名称部分. href 设置或获取整个 URL 为字符串. pathname 设置或获取对象指定的文件名或路径. port 设置或获取与 URL 关联的端口号码. protocol 设置或获取 URL 的协议部分. sear

js获取当前页面的url信息方法

例如网址:http://localhost:12085/My/OrderM.aspx 设置或获取对象指定的文件名或路径. alert(window.location.pathname) 输出结果:/My/OrderM.aspx 设置或获取整个 URL 为字符串. alert(window.location.href); 输出结果:http://localhost:12085/My/OrderM.aspx 设置或获取与 URL 关联的端口号码. alert(window.location.port

用JS获取当前页面的URL以及截取其中的字段

window.location 属性 描述 hash 设置或获取 href 属性中在井号"#"后面的分段. host 设置或获取 location 或 URL 的 hostname 和 port 号码.hostname 设置或获取 location 或 URL 的主机名称部分. href 设置或获取整个 URL 为字符串. pathname 设置或获取对象指定的文件名或路径. port 设置或获取与 URL 关联的端口号码. protocol 设置或获取 URL 的协议部分. sear

js获取iframe通过url传递的参数

获取iframe的url路径:window.parent.document.getElementById("Ateon-SetParent-iframe").contentWindow.location.search //需要iframe的ID 根据参数名称通过正则获取参数值 function geturl (name) { var reg = new RegExp("[^\?&]?" + encodeURI(name) + "=[^&]+

用js获取当前页面的url

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.设置或者获取URL的hostname或者port window.location.ho