bmwaldrop Posted February 10, 2011 Share Posted February 10, 2011 Hello,I'm trying to automatically close a lightbox that I have on my home page. With some help, I used the setTimer. However, it still doesn't close automatically. Any idea what's wrong? Thanks. <script type="text/javascript" src="/jquery.min.js"></script> <script type="text/javascript" src="/jquery.mousewheel-3.0.4.pack.js"></script> <script type="text/javascript" src="jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="jquery.fancybox-1.3.4.css" media="screen" /><script type = "text/javascript">function setCookie(isName,isVal) { document.cookie = isName + "=" + isVal + ";expires=" + "path=/";}function getCookie(isName){ cookieStr = document.cookie; startSlice = cookieStr.indexOf(isName+"="); if (startSlice == -1) {return null;} endSlice = cookieStr.indexOf(";",startSlice+1); if (endSlice == -1){endSlice = cookieStr.length} isData = cookieStr.substring(startSlice,endSlice) isValue = isData.substring(isData.indexOf("=")+1,isData.length); return isValue;}function setTimer() {setTimeout(closepopup, 5000); // 5 seconds}function closepopup(){ if(my_window.closed == false) { my_window.close (); } else {alert('Window already closed!'); }}$(document).ready(function() { if ( getCookie('myCookie') != null ) return; // no light box! setCookie('myCookie', 'ANY VALUE'); // for next time $("a#onload").fancybox({ 'frameHeight': 390, 'frameWidth': 640, 'hideOnContentClick': false, 'easingIn': 2000 }).trigger('click'); });</script> <div style="display: none;" id="lightbox_content"> <div id="data"><a href=""><img height="333" width="625" src="lightbox1.jpg" alt="" title="Lightbox" /></a> <a id="onload" href="#data"></a> Link to comment Share on other sites More sharing options...
thescientist Posted February 10, 2011 Share Posted February 10, 2011 you might not have a correct reference to the open window. Is my_window a jQuery object? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.