1

Im tryin to write to a child window using jQuery and IE9. Below is the JS with jQuery 1.7.1 code I am using:

    var w = window.open();  

    sQuery("head", w.document).append(sQuery("<link/>").attr("rel", "stylesheet").attr("href", "css/inlinecss.css"));

    sQuery("body", w.document).append(sQuery("<div/>").addClass("smdisplaychat").append(sQuery(".smdisplaychat").html()));

This code works perfect in Chrome, half way in FireFox (its losing some CSS for some reason, but that is probably a different issue), but in IE9 I get nothing but this error:

DOM Exception: HIERARCHY_REQUEST_ERR (3)

In IE9, it throws the exception when trying both statements. Looked up the error on MSDN, and its pretty generic, anybody know why I cant insert the HTML there?

Mike_G
  • 16,237
  • 14
  • 70
  • 101

1 Answers1

1

I used document.write and it seems to have worked, although it doesnt look as pretty. Below is what i changed my JS to:

  var w = window.open();

w.document.write("<!DOCTYPE html><html><head>" +
    "<link rel='stylesheet' href = 'css/inlinecss.css' />" +
    "</head><body>" + sQuery("<div/>").addClass("smdisplaychat").append(sQuery(".smdisplaychat").html()).html() +
    "</body></html>");

on a side, note, it also seems to have eliminated the FF css issue I mentioned in my OP.

Mike_G
  • 16,237
  • 14
  • 70
  • 101