js获取当前页面的网址域名地址
1.获取当前完整网址
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = ” thisURL: [" + thisURL + "]”
strwrite += ” thisHREF: [" + thisHREF + "]”
strwrite += ” thisSLoc: [" + thisSLoc + "]”
strwrite += ” thisDLoc: [" + thisDLoc + "]”
document.write( strwrite );
2.获取当前域名信息
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
strwrite = ” thisTLoc: [" + thisTLoc + "]”
strwrite += ” thisPLoc: [" + thisPLoc + "]”
strwrite += ” thisTHost: [" + thisTHost + "]”
strwrite += ” thisHost: [" + thisHost + "]”
document.write( strwrite );
3.获取当前页面
tmpHPage = thisHREF.split( “/” );
thisHPage = tmpHPage[ tmpHPage.length-1 ];
tmpUPage = thisURL.split( “/” );
thisUPage = tmpUPage[ tmpUPage.length-1 ];
strwrite = ” thisHPage: [" + thisHPage + "]”
strwrite += ” thisUPage: [" + thisUPage + "]”
document.write( strwrite );
location的属性介绍:
href 设置或获取整个 URL 为字符串。
search 设置或获取 href 属性中跟在问号后面的部分。
hash 设置或获取 href 属性中在井号“#”后面的部分。
protocol 设置或获取 URL 的协议部分。
host 设置或获取 location 或 URL 的 hostname 和 port 号码。
hostname 设置或获取 location 或 URL 的 hostname
port 设置或获取与 URL 关联的端口号码。
pathname 设置或获取对象指定的“文件名”或路径。
网页刷新推荐-JS
history.go(0)
location.reload()
location=location
location.assign(location)
document.execCommand(‘Refresh’)
window.navigate(location)
location.replace(location)
document.URL=location.href
js获取当前页面的网址域名地址的更多相关文章
- JS获取当前页面的网址链接
JavaScript获取当前页面的URL .链接地址 var currUrl = decodeURIComponent(location.href.split('#')[0]); java获取方式:h ...
- PHP中$_SERVER获取当前页面的完整URL地址
PHP中$_SERVER获取当前页面的完整URL地址,其实很简单,主要是通过$_SERVER超全局变量来实现的. 具体PHP中$_SERVER获取当前页面的完整URL地址如下. #测试网址: ...
- js获取当前页面的URL并且截取?之后的数据,返回json
js获取当前页面的URL并且截取'?'之后的数据,返回json格式的数据 最近想要把学到的东西整理一下,以后方便查找,也是一种自我累积,如果有错误或者更好的,欢迎提出! 这篇文档主要是写关于获取页面的 ...
- PHP获取当前页面的网址
PHP获取当前页面的网址 function GetCurUrl() { $url = 'http://'; if(isset($_SERVER['HTTPS']) AND $_SERVER['HTTP ...
- js获取当前页面的url网址信息小汇总
在WEB开发中,时常会用到javascript来获取当前页面的url网址信息,在这里是我的一些获取url信息的小总结. 下面我们举例一个URL,然后获得它的各个组成部分:http://i.cnblog ...
- js 获取当前页url网址信息
转载地址:js如何准确获取当前页面url网址信息 摘录: 举例一个URL,然后获得它的各个组成部分:http://i.cnblogs.com/EditPosts.aspx?opt=1 1.window ...
- 用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网址信息。
1.设置或获取整个 URL 为字符串: window.location.href 2.设置或获取与 URL 关联的端口号码: window.location.port 3.设置或获取 URL 的协议部 ...
随机推荐
- android开发架构理解
1. android 开发和普通的PC程序开发的,我觉得还是不要过度设计,因为手机开发,项目相对传统软件开发就小很多,而且手机的性能有限,过度设计代码mapping需要消耗的能相对就高,而且手机开发的 ...
- 如何快速恢复MyEclipse的默认主题
这里天在研究主题,到网上找了一些主题导入,可是有一部分主题导入后不能通过preference选项进行恢复默认主题!那怎么办?有没有别的办法! 在网上找了一些答案,有更改工作空间的办法,也有替换.set ...
- POJ3484 Showstopper (二分+字符串处理)
POJ3484 Showstopper 题目大意: 每次给出三个数x,y,z,用这三个数构成一个等差数列,x为首项,y是末项,z是公差 总共给出n组x,y,z( n待定),求这n组数列中出现次数为奇数 ...
- IOS添加自定义字体库
1.将需要的字体库xxx.ttf添加到工程中,注意一定要在copy bundle resources中存在,如果没有添加上去 2.在info.plist 文件中添加 fonts provided by ...
- 使用SQL除掉文本中特殊的ascll字符比如Enter,Tab,空格键
一.在SQL查询的字段中如果包含tab.enter.空格键,可以使用ascii码进行替换: --替换了文本中含有tab键,Enter键,空格键的ascii码 select REPLACE(REPLAC ...
- phpquery笔记
下载phpquery包 require('phpQuery/phpQuery.php');//加载 for($i=1168;$i<=10000;$i++){ phpQuery::newDocum ...
- LBS配置
js: <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak= ...
- ios晃动检测
ios晃动检测 第一种 1.在AppDelegate.h中进行如下设置: - (BOOL)application:(UIApplication *)application didFinishLaun ...
- Activiti 5.18 流程Model 转成 流程BPMN文件
直接上代码吧 byte[] bpmnBytes = null; String filename = null; JsonNode editorNode = new ObjectMapper().rea ...
- GO不支持数组通过函数参数更改,有点不一样
package main import "fmt" func modify(array []int) { array[] = fmt.Println("In modify ...