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

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

问题描述

更新:此问题有解决方法。通过包含以下元标记之一强制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,像一个Button或其他什么

  • 在IE10中运行应用程序(在Win8上)

  • 单击Silverlight应用程序中的任意位置。这只是为了集中插件。

  • 刷新页面(F5)

  • 结果:Silverlight应用程序未加载且页面为空白。

  • Create a new Silverlight application
  • Add some sort of content to MainPage.xaml, like a Button or whatever
  • Run the app in IE10 (on Win8)
  • Click anywhere within the Silverlight application. This is just to focus the plugin.
  • Refresh the page (F5)
  • Result: The Silverlight application does not load and the page is blank.

一些观察结果:


  • 完成上述步骤后,无需更新将带回申请。

  • 完成上述步骤后,如果我将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 Compat View和文档模式: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,这似乎很愚蠢!

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() ">
...

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

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