function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nishanth0208nishanth0208 

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");

btag.appendChild(btag_content);
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.
Thanks,
nishanth.

 

nishanth0208nishanth0208

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.