I'm trying to use jQuery to insert an HTML table as a child node of a div element. My code looks something like this :
var table = $('#tableId').clone();
$('#divId').append(table);
This code works fine on Chrome and Firefox, no issue, yet when I tested on Internet Explorer ( IE ) 10, the IE console throws an error like this:
SCRIPT5022: HierarchyRequestError
My internet search points me to this MSDN document :
http://msdn.microsoft.com/en-us/library/ie/gg592979(v=vs.85).aspx
It specifies that for the error message : The node cannot be inserted at the requested location. But why ?
I have tried prepend(), same error. For some reason I can't use table.appendTo(). appendTo doesn't work on all 3 browsers.
I would appreciate if someone can points me some clues how to get around this. Thanks.
Update: you can see the effect in this jsFiddle : http://jsfiddle.net/phamductri/LSaDA/ . Try Chrome and Firefox, it will work, then try IE.
Update: change the jQuery version to 1.11.0 or 2.1.0 will make the code work. But if trying to append the table into a div element in the new window, by referencing back window.opener.table : $('#divId').append(window.opener.table); This will not work in IE, though it works in Firefox and Chrome.
Update: I have discovered that this behavior is also happening when I skipped jQuery altogether and using built-in JavaScript functions. I have make another question here : Internet Explorer throws SCRIPT5022: HierarchyRequestError when trying to appendChild an HTML object from another window