Click here to Skip to main content
15,749,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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(;

     // 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") {
     } else {
          // This is a dijit widget, so call it's destroy function
Updated 6-May-13 9:27am
db7uk 6-May-13 17:08pm    
I had a similar issue. Is the silverlight app inside a div? can you not hide the div before closing the window. For me it was a z-index / display issue as modal windows over the top would not show. Maybe not what you were after but may help
GrizzlyJames 6-May-13 19:02pm    
It appears to be inside of a div. My DOM Tree is as follows (the relevant parts anyways):
<div id="mainContentBorder>
<div id="mainContent"> <!-- This is what _targetNode is from the code above -->
<iframe> <!-- This is the iframe I create, from here on, I have no control -->
<div id="silverlightControlHost">
GrizzlyJames 7-May-13 11:54am    
Turns out I can't get to the silverlightControlHost div. Everytime I try to get the contentWindow or contentDocument of the iframe I create I get an "Access is denied" error. I would imagine that's because I'm going to a different domain.

1 solution

Well I did not manage to solve this issue directly. However, there was another bug that I ran into which involved the java swing library not working on the production machine. The solution was to add the following tag as the first element of head:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"></meta>

This forces IE to use IE8 instead of IE9. This trick solved this other issue, but inadvertently solved this issue as well. Here are several links that helped lead me to the solution (amongst others):
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900