denasio — 2012-09-14T11:20:04-04:00 — #1
opener.document.getElementById("bgcolor").value = color;
opener.document.getElementById("xbgcolor").style.background = color;
After assigning the color to the 2 Id's, the popup window is closed. It worked perfect!
But now I want to use this code in an iFrame instead of a popup window.
But the code does not seem to work. Any one know how I can do the same thing in iFrame?
logic_ali — 2012-09-14T18:00:24-04:00 — #2
Don't use <!-- --> inside <script> tags.
Are you generating the iframe dynamically and do you want to remove it afterwards?
[B]parent[/B].document.getElementById("bgcolor").value = color;
[B]parent[/B].document.getElementById("xbgcolor").style.background = color;
denasio — 2012-09-14T18:10:40-04:00 — #3
Yes!! The iFrame is generated dynamically, then when the user chooses his color, the color is assigned to the variable, and the iFrame popup should be closed. Do you know how to dynamically close it?
By the way, why shouldn't I use <!-- --> inside <script> tags? I've seen this for many years to (I believe) hide the content from old browsers that doesn't support <script> .
logic_ali — 2012-09-14T19:23:57-04:00 — #4
Those comments can cause problems if you use XHTML and no usable browser needs them.
Some browsers may block iframe generation.
var ifr = parent.document.getElementById( "myIframe" /* or whatever its ID is */);
parent.document.getElementById("bgcolor").value = color;
parent.document.getElementById("xbgcolor").style.background = color;
ifr.parentNode.removeChild( ifr );
paul_wilkins — 2012-09-15T05:26:37-04:00 — #5
Netscape 2 came out in 1996, so the <!-- --> tags around script content on the page is only if you have inline scripting on your web page, which you shouldn't be doing, or if you are providing compatibility for web browsers that were around before 1996, which you shouldn't be supporting.
tl;dr Don't use <!-- --> in your scripts
system — 2014-10-07T22:55:23-04:00 — #6
This topic is now closed. New replies are no longer allowed.