如果获取“当前”域名
host = window.location.host;
url=document.domain;
url = window.location.href;
取得完整url路径: 用以下代码可以完整研证结果:
<table width=100% cellpadding=0 cellspacing=0 border=0 >
<script>
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = "<tr><td valign=top>thisURL: </td><td>[" + thisURL + "]</td></tr>"
strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr>"
strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr>"
document.write( strwrite );
</script>
thisDLoc = document.location; <BR>
thisURL = document.URL; <BR>
thisHREF = document.location.href; <BR>
thisSLoc = self.location.href;<BR>
<script>
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
strwrite = "<tr><td valign=top>thisTLoc: </td><td>[" + thisTLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisTHost: </td><td>[" + thisTHost + "]</td></tr>"
strwrite += "<tr><td valign=top>thisHost: </td><td>[" + thisHost + "]</td></tr>"
document.write( strwrite );
</script>
thisTLoc = top.location.href; <BR>
thisPLoc = parent.document.location; <BR>
thisTHost = top.location.hostname; <BR>
thisHost = location.hostname;<BR>
<script>
tmpHPage = thisHREF.split( "/" );
thisHPage = tmpHPage[ tmpHPage.length-1 ];
tmpUPage = thisURL.split( "/" );
thisUPage = tmpUPage[ tmpUPage.length-1 ];
strwrite = "<tr><td valign=top>thisHPage: </td><td>[" + thisHPage + "]</td></tr>"
strwrite += "<tr><td valign=top>thisUPage: </td><td>[" + thisUPage + "]</td></tr>"
document.write( strwrite );
</script><tr><td>
运行如下: thisDLoc = document.location;
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
thisURL:[http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
thisHREF:[http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
thisSLoc:[http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
thisDLoc:[http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
thisTLoc:[http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
thisPLoc:[http://925bb.taobao.com/js/js%E8%8E%B7%E5%8F%96url.html]
thisTHost:[925bb.taobao.com]
thisHost:[925bb.taobao.com]
thisHPage:[js%E8%8E%B7%E5%8F%96url.html]
thisUPage:[js%E8%8E%B7%E5%8F%96url.html]
分享到:
相关推荐
js 获取当前网页 1.获取当前完整网址 <script type="text/javascript"> thisURL = document.URL; thisHREF = document.location.href; thisSLoc = self.location.href; thisDLoc = document.location; strwrite = ...
47、原生JavaScript获取页面scrollLeft 48、原生JavaScript获取页面可视宽度 49、原生JavaScript获取页面宽度 50、原生JavaScript获取页面scrollTop 51、原生JavaScript获取页面可视高度 52、原生JavaScript跨浏览器...
主要介绍了JS获取url参数、主域名的方法,结合实例形式分析了javascript针对主机域名、端口、路径名、URL参数等的相关操作技巧,需要的朋友可以参考下
2、原生JavaScript获取域名主机 3、原生JavaScript清除空格 4、原生JavaScript替换全部 11、原生JavaScript加入收藏夹 15、原生JavaScript返回脚本内容 17、原生JavaScript动态加载脚本文件 23、原生JavaScript光标...
URL即统一资源定位符 (Uniform Resource Locator, URL),完整的URL由这几个部分构成: scheme://host:port/path?query#fragment scheme:通信协议,常用的http,ftp,maito等。 host:主机,服务器(计算机)域名系统 ...
javascript实现:复制代码 代码如下:top.location.href 顶级窗口的地址 this.location.href 当前窗口的地址PHP实现:复制代码 代码如下:#测试网址: http://localhost/blog/testurl.php?id=5//获取域名或主机地址 ...
//获取域名或主机地址 echo $_SERVER['HTTP_HOST']; #localhost //获取网页地址 echo $_SERVER['PHP_SELF']; #/PHP/XX.php //获取网址参数 echo $_SERVER[QUERY_STRING]; #id=5 //获取用户代理 echo $_...
原生JavaScript获取域名主机 function getHost(url) { var host = "null"; if(typeof url == "undefined"|| null == url) { url = [removed].href; } var regex = /^\w+\:\/\/([^\/]*).*/; var match = url....
最近在工作中遇到一个需求,有个页面 a.vm,对 ajax 请求的结果进行判断后,获取结果里面的数据传递给一个 URL(b.htm),跳转到新的页面 b.htm。 遇到的问题 因为一开始是 GET 请求,所以当传递的数据过大的时候,...
本书是 JavaScript 语言的参考手册,包括核心语言中的对象和客户端、服务器端的扩展。JavaScript 是 Netscape 跨平台的基于对象的适合于客户和服务器的脚本语言。 你应该已经知道的东西 在哪里能找到 JavaScript ...
URL : 统一资源定位符 (Uniform Resource Locator, URL) 完整的URL由这几个部分构成: scheme://host:port/path?query#fragment scheme = 通信协议 (常用的http,ftp,maito等) host = 主机 (域名或IP) port = 端口号...
在做html5网页开发的过程中,如果想要alert或confirm弹出信息时,苹果手机会自动带出网址,加上这段js就可以去掉网址信息
1、获取页面完整的url var a=location.href; console.log(a); // “http://www.cnblogs.com/wuxibolgs329/p/5261577.html#flag?test=12345” 2、获取页面的域名 var host = [removed].host; //www.cnblogs.com ...
JSFinder是一款用作快速在网站的js文件中提取URL,子域名的工具
获取有关任何URL的元数据。 有限的内存和网络使用情况。 这是一个node.js模块。 它使用exiftool(除了html几乎了解文件的所有信息),或者使用sax解析器以读取oembed,opengraph,twitter卡,schema.org属性或...
URL:返回或设置打开当前网页所用的URL地址 referrer:返回或设置导航到当前文件的超链接源的URL ·对象属性:对于对象数组xxx中的xxx["yyy"]与xxx.item("yyy")的主要区别在于yyy对应多个值时xxx["yyy"]返回的是...
复制代码 代码如下:<?php //获取域名或主机地址 echo $_SERVER[‘HTTP_HOST’].” ”;... 您可能感兴趣的文章:js修改地址栏URL参数解决url参数问题jQuery获取地址栏参数插件(模仿C#)JavaScript RegExp
URL属性包含页面完整的URL,domain属性中只包含页面的域名,而referrer属性中则保存着链接到当前页面的那个页面的URL。 前面两个很好理解,而referrer属性简单来说就是上一个页面的URL。那么这个属性具体有什么用处...
通过诊所域名获取完整网址的简单包 安装 使用可以: npm install vetmanager-url-getter 用法: const vm_url = require('vetmanager-url-getter'); console.log(vm_url('devtr6')); // output: ...
这个url的正则表达式判断的JavaScript!比较全面的。它验证的情况包括IP,域名(domain),ftp,二级域名,域名中的文件,域名加上端口!用户名等等信息,貌似作者也是在网上找的,我从一个项目代码中扣出来的,是我...