Zombay Posted April 11, 2011 Share Posted April 11, 2011 Why does this script need alert to work? I tested it in Firefox. <script type="text/javascript"> function fadeOut(el, frame) { alert("Why this does not work without this alert?"); var el = parent.frames[frame].document.getElementById(el); var opacity = 1; (function(){ if (opacity <= 0) { el.style.display='none'; return; } el.style.opacity = ( opacity -= 0.02); setTimeout(arguments.callee, 15); })(); } </script> <input type="submit" name="fade" value="Fade" onclick="fadeOut('fade_this','iframe');" /> <iframe src="iframe.html" height="400" name="iframe" id="iframe" frameborder="0"></iframe> iframe.html: <div id="fade_this">Fade this</div> Link to comment https://forums.phpfreaks.com/topic/233364-fadeout-and-hide-div-from-iframe-without-jquery/ Share on other sites More sharing options...
Adam Posted April 11, 2011 Share Posted April 11, 2011 It works for me without the alert. What browser are you testing with? Link to comment https://forums.phpfreaks.com/topic/233364-fadeout-and-hide-div-from-iframe-without-jquery/#findComment-1200076 Share on other sites More sharing options...
Zombay Posted April 11, 2011 Author Share Posted April 11, 2011 I was testing it at firefox 3.6.16, but I think the bug wasn't related with this script. Weird. Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/233364-fadeout-and-hide-div-from-iframe-without-jquery/#findComment-1200113 Share on other sites More sharing options...
Adam Posted April 11, 2011 Share Posted April 11, 2011 No worries. Unusual use of a closure by the way, did you write that yourself? Link to comment https://forums.phpfreaks.com/topic/233364-fadeout-and-hide-div-from-iframe-without-jquery/#findComment-1200114 Share on other sites More sharing options...
nogray Posted April 11, 2011 Share Posted April 11, 2011 Could be a load issue, make sure your script is placed in the bottom of the body and executes once the page is loaded. Link to comment https://forums.phpfreaks.com/topic/233364-fadeout-and-hide-div-from-iframe-without-jquery/#findComment-1200225 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.