Go back to main site

Internet Explorer's "No such interface supported"

screenshot

introduction

This error might be thrown by IE in multiple situations. This small article is focused on the window.open/appendChild situation. When I looked online for a solution it took me half a day to understand it, I'm sure it will eventually help someone.

situation

You are using window.open() to get access to a window and expect to alter the DOM of this new window from the originating page. This works in all browser beside IE, which complains about an "Interface not supported". Now if you want to know why you would want to update the DOM of window opened in JS, read on, if you already identified your issue and want a solution, skip to the next part "solution".

The main reason why I open windows without an URL and alter their document with JavaScript is speed. In a framework purely in JS, loading the full framework/stack in a new window has a cost. If you wonder how to do that, look at the example at the bottom of the page, you need to write a tiny DOM and close() it before accessing it.

why

Internet Exploder seems to have issues using appendChild or any DOM altering function mixing elements from different documents. Here is an example that would typically cause this error (click here to test):

  var win = window.open("", "stuff", "height=300,width=400,resizable=yes,location=no");
  var el = document.createElement("div");
  el.innerHTML = "This works!";
  win.document.body.appendChild(el);

solution with code

Another thing IE doesn't like is creating elements in a window without a DOM. Firefox will automatically create a body and everything it needs. The solution to this issue is to create all the elements AND EVENTS using the new window and not the original one. If you have a complex framework this means you will have to carry around the window/document on all your instances (yay!). Here is a piece of code that might help you visualize the solution (click here to test):

  var win = window.open("", "test2", "height=300,width=400,resizable=yes,location=no");
  win.document.writeln("<html><head><title>IE Compatible</title></head><body> </body></html>");
  win.document.close();
  setTimeout(function() {
    var el = win.document.createElement("div");
    el.innerHTML = "<h1>This works in IE too!</h1>";
    win.document.body.appendChild(el);
  }, 40);

Most JS framework already have a solution to this issue. Some will have a global variable carrying the current document all the time to avoid passing it along, some other make it implicit in their API.

(update) Internet Explorer 8

According to the below comments and emails I received, it appears that some people have been having issues with the above fix and IE8. I have personally tested the following versions, and have found the fix to work properly, so if you have an issue, you're doing it wrong ;)

comments

Steve (87.84.137.35) wrote on 2009-05-12 at 15:04:
Running IE8 on Vista and your solution doesn't work, I think we'll have wait for MS to sort this stupid problem out!
Tamentis (http://tamentis.com/) wrote on 2009-05-13 at 19:04:
Apparently, with the latest updates, this fix is still valid. I'd love to know what specific version/update does not work, so if you have issues with this fix on Vista/IE8, please send my way screenshots and version information.
Mike (http://blog.fogel.ca) wrote on 2009-07-15 at 05:05:
thanks for figuring this out....
Chris (216.16.232.90) wrote on 2009-08-10 at 19:00:
Still having an issue with your fix IE 8 windows 7
Tamentis (72.22.162.86) wrote on 2009-08-10 at 19:02:
Can you give version numbers so I can test is out?
Chris (216.16.232.90) wrote on 2009-08-11 at 17:47:
IE 8 Version is 8.0.7100.0 Win7 Build 7100
Carlos (205.240.85.235) wrote on 2009-09-29 at 15:03:
I also have this problem with IE 8 (8.0.7600.16385) and Win7 RTM.
(206.161.198.100) wrote on 2009-10-19 at 21:12:
Solution with code example doesn't work for me: IE 8 : 8.0.7600.16385 Win 7 : 6.1 build 7600
tamentis (http://tamentis.com/) wrote on 2010-01-07 at 20:56:
Alright, I got to try IE8 8.0.7100.0 Win7 Build 7100, which is as far as I can tell the default version shipping with Windows 7 Release Candidate. The above fix worked fine, I am moving this version from "Not working" to "working".
Rajesh (220.225.226.82) wrote on 2010-02-03 at 11:09:
May I know how to upgrade my IE version to "8.0.7600.16385" on Windows 7 32 bit OS. My current version of IE is 8.0.7100.0

Add a comment








Last Update: 2009-03-11 · Bertrand Janin <tamentis@neopulsar.org> · Powered by Python & Debian GNU/Linux