回调窗格更新 DOM 后 IE 不更新显示

发布于 2024-07-18 06:15:51 字数 227 浏览 6 评论 0原文

我在使用 .Net 3.5 的 ascx 页面中有一个更新面板。

用户输入数据,发起回调,ajax更新DOM。

通常一切都很顺利。 有时 DOM 会更新,而 IE 不会刷新显示。 整个更新区域似乎是空白的。

一旦用户执行了会触发刷新的操作(例如调整窗口大小),数据就会立即显示在屏幕上,但直到那时。

为什么是这样? 什么可能导致它? 如何解决?

I have an update panel in an ascx page using .Net 3.5.

The user enters data, initiates a callback, and ajax updates the DOM.

Usually everything's all hunky dory. Once in a while the DOM gets updated and IE doesn't bother refreshing the display. The entire updated area appears to be blank.

Once the user does something that would trigger a refresh, like resizing the window, the data instantly appears on the screen, but not until then.

Why is this? What could cause it? How can it be fixed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜`诱少女 2024-07-25 06:15:51

您可以通过切换到真正的浏览器来“修复”它:)

真的,您可能能够根据我发现的技巧来修复它在此页面

基本上,您需要做的是创建一个空节点,并在使用新内容更新 DOM 后在本地删除它:

var t = document.createTextNode('temp text');
element.appendChild(t); // Not sure if this is any element
                        // or one inside your new DOM nodes.
setTimeout(function() { t.parentNode.removeChild(t); }, 0);

在该页面中,作者说:

即使有了我的“修复”,它也只有在以下情况下才有效:
用户将鼠标光标移出
离开窗口并返回。

但我想这已经是最好的了...我认为 IE 可能不会触发刷新,除非浏览器窗口上有一些活动,以节省处理时间

很长一段时间以来,这一直是 IE 中一个已知的非常烦人的错误,尽管我在任何地方都找不到它。 事实上,即使是 Opera 也会时不时地出现这样的错误。

另外,即使您使用该技巧解决了该问题,也要检查每个 HTML 片段是否有效。 您可以在 http://validator.w3.org 中查看。 如果某段代码无效,那么你不能责怪浏览器不理解你的意思。

You can 'fix' it by switching to real browsers :)

Really, you might be able to fix it according to the trick I found in this page.

Basically, what you need to do is create an empty node and delete it locally after you update the DOM with your new content:

var t = document.createTextNode('temp text');
element.appendChild(t); // Not sure if this is any element
                        // or one inside your new DOM nodes.
setTimeout(function() { t.parentNode.removeChild(t); }, 0);

In that page the author says:

Even with my "fix," it only works if
the user moves their mouser cursor out
of the window and back in.

But I guess that's as good as it gets... I think IE may not be triggering a refresh unless there's some activity on the browser window, to save processing time.

That's been a known really annoying bug in IE for a long time now, although I can't find it posted anywhere. In fact, even Opera has that bug from time to time.

Also, even if you solve it using that trick, check that every single piece of HTML is valid. You can check it in http://validator.w3.org. If some piece of code is invalid, then you can't blame the browser for not understanding what you meant.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文