最近发现一个问题:
window.location.href在IE6下面竟然不跳转,这是为什么呢?
这个是我写的语句:
<
a href
=
"
javascript:void(0);
"
;onclick
=
"
javascript:window.location.href='http://www.sina.com';
"
>转到新浪
<
/
a>
后面是网上找到了解决方案(URL:http://www.cnblogs.com/kaima/archive/2008/08/22/1273808.html):
<script type="text/javascript">
function goUrl(x)
{
window.location.href=x;
}
</script>
<a href="javascript:;" onclick="javascript:goUrl('http://www.sina.com');">跳转1</a>
<a href="javascript:void(0);" onclick="javascript:goUrl('http://www.sina.com');">跳转2</a>
<a href="javascript:void(0);" onclick="javascript:goUrl('http://www.sina.com');return false;">跳转3</a>
<a href="#" onclick="javascript:goUrl('http://www.sina.com');">跳转4</a>
<a href="###" onclick="javascript:goUrl('http://www.sina.com');">跳转5</a>
测试环境IE6,IE7,Firefox 3。
跳转1和2在IE6环境下无效,3、4、5在IE6,IE7,Firefox3.01下测试均能 通过,。
跳转4和5最简洁。
关键在于<a>的href属性,空链接用"#","###"。
为了不返回网页顶端。
空链接推荐用"###"。
我采用了第三种方法,在后面加了return false;这样,IE6、IE7、FF3下面全部通过。
分享到:
相关推荐
window.location.href页面跳转的用法(区别于redirect)
一、location.href常见的几种形式 self.location.href;//当前页面打开URL页面 [removed].href;//当前页面打开URL页面 this.location.href;//当前页面打开URL页面 location.href;// 当前页面打开URL页面 parent....
“[removed].href”、”location.href”是本页面跳转 “parent.location.href”是上一层页面跳转 “top.location.href”是最外层的页面跳转 举例说明: 如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的...
javascript 打开页面window.location和window.open的区别.docx
详解js location.href和window.open的几种用法和区别.docx
NULL 博文链接:https://hugang357.iteye.com/blog/1833003
window.opener.location.href = window.opener.location.href 刷新以winodw.showModelDialog()方法打开的窗口 window.parent.dialogArguments.document.execCommand('Refresh'); 或 Response.Write("<script>...
针对window.location.href在ie6下不能跳转问题详解
window.postMessage的功能是允许程序员跨域在两个窗口/frames间发送数据信息。基本上,它就像是跨域的AJAX,但不是浏览器跟服务器之间交互,而是在两个客户端之间通信。让我们来看一下window.postMessage是如何工作...
简单的说:几种location.href的区别 js实现网页被iframe框架功能 “[removed].href”、”location.href”、”self.location.href”是本页面跳转 “parent.location.href”是上一层页面跳转 “top.location.href”是...
window.clearInterval与window.setInterval的用法.
document 表示的是一个文档对象,windows 表示一个窗口对象。... 发现,这两个的值不一样, document.URL : //www.jb51.net/ windows.location.href ://www.jb51.net/#server 所以,如果要用 fragment 进行
对window.open进行封装, 使其更好用, 且更兼容, 很多人说window.open不兼容,其实不是, 因为不能直接执行, 必须通过用户手动触发才行;看代码: 代码如下 var openWindow = function(url, options) { var str = ""; ...
window.showModalDialog以及window.open用法简介
window.location.href location.search; //获取url中"?"符后的字串 document.referrer 获取来路的url,相当于php的$_SERVER['HTTP_REFERER']。 encodeURIComponent() 对url进行转定义,相当于php的urlencode()...
This is a `window.showModalDialog()` shim using a modal HTML5 `<dialog>` element and ECMAScript 6 Generators. It was tested in the latest Google Chrome with the *Enable Experimental JavaScript* flag ...
window.parent调用父框架时,ie跟火狐不兼容问题!
Window.open ('page.html') 用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。用单引号和双引号都可以,只是不要混用。 这一段代码...