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> Quote 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? Quote 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! Quote 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? Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.