+ Start a Discussion

Error with CreateTextNode in Internet Explorer(IE)

Hi All,

I am using CreateTextNode on my page in the process of displaying some content on my page like below.



var btag=document.createElement("h2");


var btag=document.createElement("h2");

var btag_content = document.createTextNode("Subject");

var sp2 = document.getElementById("output");
var parentDiv = sp2.parentNode;
parentDiv.insertBefore(btag, sp2);
In this context, i am getting an error in Internet Explorer as  "ERROR:unExpected call to method or property access"

While debugging i came to knw that this is happening because of CreateTextNode method call. How can i overcome this error in IE. My code works well in Chrome.
Please suggest me the remedy.



It works fine in IE till we try to create some hard coded text like "demo text" like that. But when we try to display some dynamically generated content using query, then it is reporting the above mentioned error.