JS获取当前页面的URL
如果获取“当前”域名
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获取当前页面的URL的更多相关文章
- js获取当前页面的URL并且截取?之后的数据,返回json
js获取当前页面的URL并且截取'?'之后的数据,返回json格式的数据 最近想要把学到的东西整理一下,以后方便查找,也是一种自我累积,如果有错误或者更好的,欢迎提出! 这篇文档主要是写关于获取页面的 ...
- js获取当前页面的url网址信息小汇总
在WEB开发中,时常会用到javascript来获取当前页面的url网址信息,在这里是我的一些获取url信息的小总结. 下面我们举例一个URL,然后获得它的各个组成部分:http://i.cnblog ...
- 用js获取当前页面的url的相关信息方法
当前页面对应的URL的一些属性: ( http://bbs.xxx.net/forum.php?mod=viewthread&tid=2709692&page=1&extra= ...
- js获取当前页面的url网址信息
设置或获取整个 URL 为字符串: window.location.href 获取内容:http://10.100.0.8:7000/SVP/ "window.location.href&q ...
- JS获取当前页面的URL信息
设置或获取对象指定的文件名或路径. <script> alert(window.location.pathname) </script> 设置或获取整个 URL 为字符串. & ...
- js获取当前页面的url信息方法
例如网址:http://localhost:12085/My/OrderM.aspx 设置或获取对象指定的文件名或路径. alert(window.location.pathname) 输出结果:/M ...
- 使用js获取当前页面的url网址信息。
1.设置或获取整个 URL 为字符串: window.location.href 2.设置或获取与 URL 关联的端口号码: window.location.port 3.设置或获取 URL 的协议部 ...
- js获取当前页面的url中id
function UrlSearch() { var name, value; var str = location.href; //获取到整个地址 var num = str.indexOf(&qu ...
- js获取当前页面的url地址
//微信分享的时候要通过这样动态获取url传参,因为微信会对url自动加参数,所以要动态获取,不能写死url var page_url = location.href.split('#')[0];
随机推荐
- OceanBase数据库实践入门——手动搭建OceanBase集群
前言 目前有关OceanBase功能.案例.故事的文章已经很多,对OceanBase感兴趣的朋友都想安装一个数据库试试.本文就是分享初学者如何手动搭建一个OceanBase集群.这也是学习理解Ocea ...
- module has no attribute 'seq2seq'
tensorflow 中tf.nn.seq2seq.sequence_loss_by_example to tf.contrib.legacy_seq2seq.sequence_loss_by_exa ...
- linux的history命令设置
history的历史记录,同一个用户的各个会话,读取到的内容也是不一样的,原因是它读取的是shell会话缓存里的内容.只有当用户退出当前会话的时候,会话里的缓存内容才会写入~/.bash_histor ...
- poj-3744-Scout YYF I-矩阵乘法
f[i]=f[i-1]*p+f[i-2]*(1-p); 正好能够用矩阵加速. . . . #include<stdio.h> #include<string.h> #inclu ...
- AngularJS的简单表单验证
代码下载:https://files.cnblogs.com/files/xiandedanteng/angularjsCheckSimpleForm.rar 代码: <!DOCTYPE HTM ...
- Unity3d载入外部图片文件
unity里的图片在生成时会压缩成资源文件,有时客户想自己放一些图片用unity显示,就必须载入外部图片. 大体思路:用Application.streamingAssetsPath或Applicat ...
- 向odoo贡献中文翻译
建议通过 osc-git向odoo贡献中文翻译 osc-git 是指'开源中国'的git平台. 网址是 http://git.oschina.net/ 注册osc-git 账号省略. ...
- Codeforces Round #267 (Div. 2) B. Fedor and New Game
After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...
- Android性能优化之中的一个 布局优化
本文为Android性能优化--布局优化,主要介绍使用抽象布局标签(include, viewstub, merge).去除不必要的嵌套和View节点.降低不必要的infalte及其它Layout方面 ...
- 看完此文,妈妈还会担心你docker入不了门?
本文在个人技术博客不同步发布,详情可猛戳 亦可扫描屏幕右侧二维码关注个人公众号,公众号内有个人联系方式,等你来撩... 上周对象突然心血来潮说想养个小宠物,我问想养啥她又说随便,你看着办!!!这我 ...