0

I get this script error “Invalid argument” when using appendChild(). When in Microsoft Visual Studio Debugger I see “htmlfile: Invalid argument”, and the line it blows up on is t.appendChild(n);

The div I want to append the child div to is the top most div in the dom.
Anyone see what I am doing wrong here?

var t = document.parentWindow.parent.parent.document.getElementById("mod"); 
var n = document.createElement("div");
n.setAttribute("id", "c_dlg"); 
t.appendChild(n);

Thanks

5
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by ddsuresh
0

This is late reply to this post but it might help someone searching with this problem.

I found that creating the new element within the same document I needed to append to fixed a similar problem I was having.

So in this case creating the new div like this may be a fix for this problem:

document.parentWindow.parent.parent.document.createElement("div");

Hope this helps someone.

0

This is late reply to this post but it might help someone searching with this problem.

I found that creating the new element within the same document I needed to append to fixed a similar problem I was having.

So in this case creating the new div like this may be a fix for this problem:

document.parentWindow.parent.parent.document.createElement("div");

Hope this helps someone.

This solved my problem, thanks!

0

This is late reply to this post but it might help someone searching with this problem.

I found that creating the new element within the same document I needed to append to fixed a similar problem I was having.

So in this case creating the new div like this may be a fix for this problem:

document.parentWindow.parent.parent.document.createElement("div");

Hope this helps someone.

After a long search, i got this post and my problem is solved.

Thanks,
Suresh
<FAKE SIGNATURE>

Edited by peter_budo: Keep It On The Site - Do not manually post &quot;fake&quot; signatures in your posts.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.