javaScript获取当前Url的方法
2016-02-17 09:58
711 查看
1.(获取全部的url)
方法1:var thisURL = document.URL; // http://localhost:81/admin/welcome.htm?Did=123
方法2:var thisHref = document.location.href; // http://localhost:81/admin/welcome.htm?Did=123
方法3:var thisURL = self.location.href; // http://localhost:81/admin/welcome.htm?Did=123
方法4:var thisURL = document.location; // http://localhost:81/admin/welcome.htm?Did=123
2.(适用于frame框架下获取链接)
方法1:var thisTLoc = top.location.href; // http://localhost:81/admin/index.html
方法2:thisPLoc = parent.document.location; // http://localhost:81/admin/index.html
3. (获取网址)
方法1:var thisTHost = top.location.hostname; // localhost
方法2:var Url= location.hostname; // localhost
4.(获取url中不同部分)
thisU1 = window.location.protocol; // http:
thisU2 = window.location.host; // localhost:81
thisU3 = window.location.pathname; // /admin/index.html
方法1:var thisURL = document.URL; // http://localhost:81/admin/welcome.htm?Did=123
方法2:var thisHref = document.location.href; // http://localhost:81/admin/welcome.htm?Did=123
方法3:var thisURL = self.location.href; // http://localhost:81/admin/welcome.htm?Did=123
方法4:var thisURL = document.location; // http://localhost:81/admin/welcome.htm?Did=123
2.(适用于frame框架下获取链接)
方法1:var thisTLoc = top.location.href; // http://localhost:81/admin/index.html
方法2:thisPLoc = parent.document.location; // http://localhost:81/admin/index.html
3. (获取网址)
方法1:var thisTHost = top.location.hostname; // localhost
方法2:var Url= location.hostname; // localhost
4.(获取url中不同部分)
thisU1 = window.location.protocol; // http:
thisU2 = window.location.host; // localhost:81
thisU3 = window.location.pathname; // /admin/index.html
相关文章推荐
- ExtJS获取父子、兄弟容器元素方法
- easelJS 初始入门
- js将map转成数组
- 关于一个JS功能实现的思维方式
- QJSon的编译
- QJson的编译和安装--------可行
- JSP中文乱码
- QJson使用
- Javascript实现图片轮播效果(二)图片序列节点的控制实现
- C#后台调用前台js(RegisterStartupScript)
- Javascript实现图片轮播效果(一)让图片跳动起来
- 2016.02.17 JS DOM编程艺术 第四五六章
- JavaScript学习2--对象
- 加载JS
- 基于javascript简单实现对身份证校验
- JavaScript学习1
- js 比较好的博客
- JavaScript 笔记 8 - Number对象
- JavaScript与PHP基础知识对比学习
- JSP入门之HelloWorld程序实例