By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,317 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,317 IT Pros & Developers. It's quick & easy.

how to appendChild to iframes

P: n/a
var iframe = document.createElement("<IFRAME id='frame0' style='PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px' border='no' name='frame0' src='RasteriserServlet?width=200&amp;height=200&am p;bgColor=#FFFFFF&amp;fgColor=#000000' frameBorder='no' width='200' scrolling='no' height='200' menuId='formControlPopup' childName='frame' showLable='true' labelPosition='bottom'>");

var form = document.createElement("<FORM action='RasteriserServlet?' name='form0' childName='form' method='Post' id='form0'>");
iframe.appendChild(form);

or

iframe.insertBefore(form);
doesn't works "Unexpected call to method or property access."

So,
how to appendChild to iframes?


--
Thank you,
De Cool,
EPE
Jun 21 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jun 21, 1:07 pm, "Dmitry Kulinich" <d...@isd.dp.uawrote:
var iframe = document.createElement("<IFRAME id='frame0' style='PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px' border='no' name='frame0' src='RasteriserServlet?width=200&amp;height=200&am p;bgColor=#FFFFFF&amp;fgColor=#000000' frameBorder='no' width='200' scrolling='no' height='200' menuId='formControlPopup' childName='frame' showLable='true' labelPosition='bottom'>");

var form = document.createElement("<FORM action='RasteriserServlet?' name='form0' childName='form' method='Post' id='form0'>");

iframe.appendChild(form);

or

iframe.insertBefore(form);
doesn't works "Unexpected call to method or property access."

So,
how to appendChild to iframes?

--
Thank you,
De Cool,
EPE
Several issues:
To my knowledge, you can't create elements with

var td = document.createElement( "<td id='bla' width='100%'>" );

but with

var td = document.createElement( "td" );
td.setAttribute( "id", "bla" );
td.setAttribute( "width", "100%" );
etc.

Now, I used TD as an illustration, it should of course refer to the
iframes as well. Maybe there's some part of DOM that parses the
strings in the fashion you used them, but I'm not familiar with that.

Second, iframes are actually a form of windows, not DOM nodes, that in
themselves container documentElement and documentElement in its self
contains Elements. So, what you should do is find the iframe's
contentWindow, then its document element, and then you can find the
'body' element of the document; then you can append children to the
latter.

So, what you should probably do is something like this: (not tested,
but just pointing the direction)

var iframe = document.createElement("IFRAME" );
iframe.id = 'frame0';
iframe.setAttribute( "style", 'PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
PADDING-BOTTOM: 0px; PADDING-TOP: 0px'" );
iframe.setAttribute( "border, 'no' );
iframe.setAttribute( "name", 'frame0' );
iframe.setAttribute( "src", 'RasteriserServlet?
width=200&amp;height=200&amp;bgColor=#FFFFFF&amp;f gColor=#000000' );
iframe.setAttribute( "frameBorder", 'no' );
.....

var form = document.createElement( "FORM" );
form.setAttribute( "action", 'RasteriserServlet?' );
form.setAttribute( "name", 'form0' );
.....

iframe.contentWindow.document.body.appendChild( form );

I don't know if this is going to work though, cause just creating the
"iframe" element shouldn't create all of its necessary children I
named above, such as contentWindow, its corresponding document, body,
etc. elements.
So, maybe, the thing you're doing maybe isn't the best idea in the
very root of its concept?

Jun 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.