原文:http://blog.csdn.net/yongh701/article/details/45688743 版权声明:本文为博主原创文章,未经博主允许欢迎乱转载,标好作者就可以了!感谢欣赏!觉得好,回个贴就行! 利用JavaScript获取当前页的URL,这个问题起来好像很复杂,如果第一次去想这个问题,很多人估计又在琢磨到底又是哪个神一般的Javascript函数. 其实不是,Javascript获取当前页的URL的函数就是我们经常用来重定向的window.location.href.…
今天遇到个很诡异的问题,就是<a href="javascript:void(0);" onclick="window.location.href=url"></a>在IE6下面没反应,不跳转到onclik事件中的“window.location.href”. 当时我们在网上找了篇文章很快就解决了,但是文章中没有说明具体原因在哪里,只是说在“window.location.href”后面加一个"return false",…
document.URL vs window.location.href All In One document.URL 与 window.location.href 两者有啥区别 document.URL; window.location.href; ??? 啥区别 兼容性 不同 https://caniuse.com/?search=document.URL https://caniuse.com/?search=window.location.href Document API https…
实际上,document 和 window 这两个对象的区别已经包含了这个问题的答案. document 表示的是一个文档对象,window 表示一个窗口对象. 一个窗口下面可以有很多的document对象.每个document 都有 一个URL. 但是,这不是所有的区别.当你ctrl + F5 一个链接 http://yourhost.com/#fragment 打印 alert(document.URL ); 和 alert(window.location.href); 发现,这两个的值不一…
window.location是页面的位置对象window.location.href是 location的一个属性值,并且它是location的默认属性. window.location直接赋值一个url实际上就是对window.location.href赋值. location对象除了有href属性外还有很多其他属性. 上个图更清晰: 从图上可以看出来每一部分的表示,举个例子 location.pathname -- 返回URL的域名后的部分.例如 https://www.baidu.com…
当前页面对应的URL的一些属性: ( http://bbs.xxx.net/forum.php?mod=viewthread&tid=2709692&page=1&extra=#pid23817304) 1)当前页面的完整的URL: window.location.href 2)当前页面的URL的pathname: window.location.pathname (http://bbs.xxx.net/forum.php) 3)当前页面的URL的问号后面的查询部分: window…
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…
使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href常见的几种形式 目前在开发中经常要用到的几种形式有: 1 2 3 4 5 6 self.location.href;//当前页面打开URL页面 window.location.href;//当前页面打开URL页面 this.location.href;//当前页面打开URL页面 location.h…
windows.open("URL","窗口名称","窗口外观设定");打开新窗口,window对象的方法 不一定打开新窗口,只要有窗口的名称和window.open中第二个参数中的一样就会将这个窗口替换,可以iframe.frame中代替location.href <iframe name="a"></iframe> <input type=button onclick="window…
问题情况 JS中设置window.location.href跳转无效 代码如下: ? 1 2 3 4 5 6 7 8 <script type="text/javascript">    function checkUser() {      if(2!=1){         window.location.href="login.jsp";       } }   </script> 原因是 a标签的href跳转会执行在window.lo…