Silverlight 应用程序在 IE10 中的页面刷新时消失 [英] Silverlight app disappears on page refresh in IE10

查看:19
本文介绍了Silverlight 应用程序在 IE10 中的页面刷新时消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:该问题有一个解决方法.它是通过包含以下元标记之一来强制 IE10 进入兼容模式:

UPDATE: There is a workaround to the problem. It is to force IE10 into compatibility mode by including one of the following meta tags:

<meta http-equiv="x-ua-compatible" content="IE=7" />
<meta http-equiv="x-ua-compatible" content="IE=8" />

由于种种原因,这并不是一个真正完美的解决方案,但它至少消除了问题.

This is not really a perfect solution for various reasons, but it eliminates the problem at least.

原问题:
几个月前,我意识到 Windows 8 上的 IE10 中的 Silverlight 应用程序存在问题(我还没有尝试过 Windows 7 的 IE10 预览版).当托管我们的 SL 应用程序的 asp.net 页面首次加载时,一切正常,应用程序按预期加载.如果我立即刷新页面,它也会按预期重新加载.但是:如果我通过单击将 Silverlight 应用程序聚焦然后按 F5,它就会变成空白.就像插件完全消失一样.如果我使用 Fiddler 跟踪请求,我可以看到没有为 xap 文件发出请求.我一直希望这会在 IE10 的补丁版本中得到修复,但到目前为止没有任何改变.当我尝试使用谷歌搜索时,我找不到任何关于此的信息.我似乎不太可能是第一个发现它的人,我很惊讶我没有找到更多信息.重现问题:

ORIGINAL QUESTION:
I realised a couple of months ago that there is a problem with our Silverlight application in IE10 on Windows 8 (I have not tried the IE10 preview for Windows 7). When the asp.net page hosting our SL app first loads everything works fine and the application loads as expected. If I refresh the page immediately, it also reloads as expected. But: If I focus the Silverlight application by clicking in it and THEN hit F5, it just goes blank. It is like the plugin disappears completely. If I trace the requests using Fiddler I can see that no request is issued for the xap file. I have been hoping that this would be fixed in a patch release for IE10, but so far nothing has changed. I cannot find any information about this when I try googling it. It seems highly unlikely that I should be the first person to discovered it and I am quite surprised that I am not finding more information. To reproduce the issue:

  • 创建一个新的 Silverlight 应用程序
  • 向 MainPage.xaml 添加某种内容,例如按钮或其他内容
  • 在 IE10(在 Win8 上)中运行应用
  • 单击 Silverlight 应用程序中的任意位置.这只是为了聚焦插件.
  • 刷新页面 (F5)
  • 结果:Silverlight 应用程序未加载且页面为空白.

一些观察:

  • 完成上述步骤后,再多的刷新也不会使应用程序恢复原状.
  • 执行上述步骤后,如果我将 url 重新输入地址栏中并按 Enter,应用程序将按预期加载.
  • 如果我在 IE 中启用兼容性视图,应用程序也会按预期加载.启用兼容性视图后,我所做的任何事情都不会重现该错误.

现在我的问题:

  1. 有没有其他人观察到这种行为?
  2. 如果是,您是否找到了解决方法?

推荐答案

我在 IE 10 中的 Silverlight 应用程序中发现了同样的问题.

I'm seeing the same issue with my Silverlight application in IE 10.

我已尝试添加上面建议的 IE 8 兼容性元标记,但这并不能始终如一地解决问题.在说每 5 次刷新尝试之后,它似乎只是间歇性地工作?!

I've tried adding the IE 8 compatibility meta tag suggested above, but this does not resolve the problem consistently. It seems to work only intermittently, after say every 5th refresh attempt?!

我认为要始终如一地解决此问题的唯一方法是强制浏览器模式进入IE 10 兼容性视图",我认为这不能通过页面内容(元标记等)来完成?我不得不删除 IE 8 兼容性元标记,以便地址栏中的兼容性视图"按钮可用,然后要求用户单击兼容性按钮,然后站点会记住该按钮.这导致浏览器进入浏览器模式:IE 10 兼容视图"和文档模式:IE7 标准".然后刷新行为会按预期和以前一样一致地工作.

The only way I can see to work around this consistently is to force the Browser Mode into "IE 10 Compatibility View", and I don't think this can be done via page content (meta tag, etc.)? I've had to remove the IE 8 compatibility meta tag so that the "Compatibility View" button is available in the address bar, and then ask users to click the compatibility button, which is then remembered for the site. This results in the browser entering Browser Mode: "IE 10 Compat View" and Document Mode: "IE7 Standards". The refresh behaviour then works consistently as expected and as it used to.

这对我们来说是个大问题.我们已经构建了我们的 Silverlight 应用程序,这样浏览器刷新按钮用于刷新应用程序内的页面/内容(用户保持登录状态等).我们不得不要求用户将我们的网站设置为在兼容模式下运行,这样刷新功能才能按预期工作,这真的很糟糕.

This is a big problem for us. We've built our Silverlight app such that the browser refresh button is used to refresh pages/content within the app (the users stays logged in, etc.). It's really bad that we have to ask users to set our site to run in compatibility mode for the refresh functionality to work as expected.

请注意,这在 Chrome 中仍然可以正常工作.由于这个问题,我们可能需要推荐我们的用户使用 Chrome,这似乎很愚蠢!

Note that this still works as expected in Chrome. It seems silly that we might need to recommend that our users use Chrome because of this issue!

更新:

一种解决方法似乎是始终使用 JavaScript 将 Silverlight 对象动态加载到其托管页面中.

A workaround for this seems to be to always load the Silverlight object into its hosting page dynamically using JavaScript.

例如

function onLoad() {
  var silverlightControlHost = document.getElementById("silverlightControlHost");
  silverlightControlHost.innerHTML = "<object ...

更新 2:

这是我用来解决此问题的最新代码:

Here is the latest code I use to work around this issue:

...
        function unloadSilverlight() {
            document.getElementById("silverlightControlHost").innerHTML = "";
        }

        function focusOnSilverlight() {
            document.getElementById("silverlightObject").focus();
        }

        function onLoad() {
            window.onbeforeunload = unloadSilverlight;
            setTimeout(focusOnSilverlight);
        }
    </script>
</head>
<body onload=" onLoad() ">
...

这篇关于Silverlight 应用程序在 IE10 中的页面刷新时消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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