Log in

View Full Version : Lightbox Script that appears after a specific duration



rk1708
02-27-2013, 08:40 AM
Dear All,


I'm looking for a script that can be implemented sitewide and a lightbox appears when the user stays for more than 30 seconds on the website or on any page,
I found this one but it is on body load event http://visuallightbox.com/rq/automatically-open-the-lightbox-popup-upon-opening-the-page-r.html

Please help me out guys, Its urgent

jscheuer1
02-27-2013, 02:36 PM
Something like that can be done with any lightbox type script. The exact coding varies, and that script can do it in other ways. That said, taking the code given there, all you would need to do is to lengthen the timeout to 30 seconds:


<script type="text/javascript">
var started;
function showLightBox()
{
if (started) return;
started = setTimeout(function(){
Lightbox.start(document.getElementById('firstImage'));
started;
}, 30 * 1000);
}
</script>

I would skip the body onload bit and use this version:


<script type="text/javascript">
(function($){
var started;
function showLightBox(){
if (started) return;
started = setTimeout(function(){
Lightbox.start(document.getElementById('firstImage'));
started = true;
}, 30 * 1000);
}
$(window).load(showLightBox);
})(jQuery);
</script>