本文介绍了来自iframe的Silverlight 5 app在IE9中没有关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Dojo v1.8开发一个Web应用程序,我的目标机器运行IE9和Silverlight 5.1.20125。在此Web应用程序中,用户可以从页面顶部的工具栏中选择一个工具,该工具栏将在工具栏下方的内容窗格(或IFrame,如果它是外部工具)中打开(只有一个工具可以在时间)。



我遇到的错误是在IFrame中打开的一个外部工具运行Silverlight应用程序,如果用户尝试选择其他工具,新工具将无法打开,Silverlight应用程序将保留在那里。在检查DOM树之后,所有对Silverlight应用程序的引用都已被擦除,而新工具就在那里(这是所需的行为)。



所以我的问题是的,为什么Silverlight应用程序即使从DOM树中消失也仍然被查看,有没有办法以编程方式从Javascript中关闭它?此外,我无权访问Silverlight应用程序的源代码。



清除包含当前工具的div(_targetNode)的代码如下:



  while (_ targetNode.hasChildNodes()){
var widgetInstance = dijit.byId(_targetNode.lastChild.id);

// 如果未定义,则该工具不是dijit小部件
if typeof widgetInstance == undefined){
// 我第一次尝试解决这个问题。它没有任何效果。
if (_ targetNode.lastChild.tagName.toUpperCase()== IFRAME){
_targetNode.lastChild.contentWindow.close();
}
_targetNode.removeChild(_targetNode.lastChild);
} 其他 {
// 这是一个dijit小部件,所以称之为销毁功能
widgetInstance.destroy();
}
}
解决方案

I am developing a web application using Dojo v1.8 and my target machine runs IE9 and Silverlight 5.1.20125. In this web app, the user can select a tool from a toolbar at the top of the page that will open up in a content pane (or an IFrame if it is an external tool) below the toolbar (only one tool can run at a time).

The bug I am encountering is that one of the external tools that opens in an IFrame runs a Silverlight app, and if the user tries to select another tool, the new tool won't open and the Silverlight application stays there. After checking the DOM Tree, all references to the Silverlight application have been wiped, and the new tool is there instead (which is the desired behavior).

So my question is, why is the Silverlight Application still being viewed even when it is gone from the DOM Tree, and is there a way to programmatically close it from Javascript? Also, I do NOT have access to the source code of the Silverlight Application.

The code for clearing out the div (_targetNode) which holds the current tool is as follows:

while(_targetNode.hasChildNodes()) {
     var widgetInstance = dijit.byId(_targetNode.lastChild.id);

     // If this is undefined, then the tool is not a dijit widget
     if (typeof widgetInstance == "undefined") {
          // My first attempt to resolve the issue.  It had no effect.
          if(_targetNode.lastChild.tagName.toUpperCase() == "IFRAME") {
               _targetNode.lastChild.contentWindow.close();
          }
          _targetNode.removeChild(_targetNode.lastChild);
     } else {
          // This is a dijit widget, so call it's destroy function
          widgetInstance.destroy();
     }
}
解决方案


这篇关于来自iframe的Silverlight 5 app在IE9中没有关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 14:36