954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

htmlfile: Invalid argument error using AppendChild

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

Sailor_Jerry
Junior Poster in Training
88 posts since Aug 2005
Reputation Points: 13
Solved Threads: 2
 

Could you post the corresponding HTML code?

BudBrocken
Newbie Poster
9 posts since Oct 2006
Reputation Points: 10
Solved Threads: 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.

oxymeboy
Newbie Poster
1 post since Jul 2007
Reputation Points: 10
Solved Threads: 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!

sporter
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 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

ddsuresh
Newbie Poster
8 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You