在框架设定的location.hash [英] Setting location.hash in frames

查看:157
本文介绍了在框架设定的location.hash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Ajax来更新页面在一个框架中的位置。但设置散列(在Chrome)明确,但偶尔在IE7和某些版本的IE浏览器(5.5)的位置时,页面被重新加载。

I am using ajax to update the location of a page in a frame. But when setting the location of the hash (on Chrome and some versions of IE (5.5) specifically, but occasionally on IE7) the page is being reloaded.

下面的HTML演示该问题。

The following html demonstrates the problem.

主框架.... frame.html是

the main frame.... frame.html is

<html><head>
<frameset rows="*">
<frame src=sethash.html frameborder=0 scrolling=auto name=somebody>
</frameset>
</head></html>

在sethash.html页面。

the sethash.html page is .

<html><head>
<script language=JavaScript>
var Count = 0;
function sethash()
{  
  top.document.location.hash = "hash" + Count;  
  Count++;
}
</script>
</head>
<body onload="alert('loaded')">
<h1>Hello</h1>
<input type='button' onClick='sethash()' value='Set Hash'>
</body>
</html>`

在大多数浏览器加载frame.html将显示加载的警报时,一次在页面加载。然后,当设定的哈希键是pressed URL将被改变,但哈希加载警报将不再显示。对铬和某些版本即对

On most browsers loading the frame.html will show the loaded alert once when the page is loaded. Then when the set hash button is pressed the url will be changed but the hash the loaded alert will not show again. On chrome and some versions of I.E

微软的报告可能是同样的问题,在Internet Explorer 5.5 链接文本

Microsoft report possibly the same problem with Internet Explorer 5.5 link text

我不能使用微软建议的解决方案,这是捕获事件不火,但只是滚动到视图,因为现在用的设置top.location.hash为onLoad事件的一部分。

I can't use the microsoft suggested solution, which is to capture the event and not fire it, but just scroll into view, as am using set the top.location.hash as part of the onLoad event.

推荐答案

的Webkit(通过扩展,Chrome浏览器)运行异常带的location.hash。有一个关于它的一些开放的错误,最相关的大概是这样的一种:<一href="https://bugs.webkit.org/show%5Fbug.cgi?id=24578">https://bugs.webkit.org/show_bug.cgi?id=24578的文档您具有刷新页面时的location.hash改变的问题。它看起来像你的最佳选择,现在是用你的手指,并希望它得到及时解决。

Webkit (and by extension, Chrome) behave strangely with location.hash. There are a few open bugs about it, the most relevant is probably this one: https://bugs.webkit.org/show_bug.cgi?id=24578 that documents your problem of having the page refresh when location.hash is changed. It looks like your best option right now is to cross your fingers and hope that it gets promptly fixed.

我无法重现在IE7中的错误,虽然,你在时代的第一人我见过,支持IE5.5,所以我真的不能帮你那里;)

I can't reproduce the bug in IE7 though, and you're the first person in ages I've seen that supports IE5.5 so I can't really help you there ;)

这篇关于在框架设定的location.hash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆