Display the FancyBox after certain seconds?!

789 views
Skip to first unread message

Mohammad Mafi

unread,
Jan 2, 2010, 6:00:47 AM1/2/10
to fancybox
Hello and thanks for this awesome script

I want the FancyBox to start automatically after certain amount of
seconds on page loading?!
Is it possible?!
Thanks

Mohammad Mafi

unread,
Jan 3, 2010, 6:36:36 AM1/3/10
to fancybox
Any help?!
Thanks

Mohammad Mafi

unread,
Jan 4, 2010, 1:50:39 PM1/4/10
to fancybox
Somebody help me, please!!

JFK

unread,
Jan 5, 2010, 1:11:37 AM1/5/10
to fancybox
ok, ok, ok 3 steps

1). insert this script somewhere:
(respect the copyright)

<script type="text/javascript">
$(document).ready(function() {
/**
* jQuery Delay - A delay function
* Copyright (c) 2009 Clint Helfers - chelfers(at)gmail(dot)com |
http://blindsignals.com
* Dual licensed under MIT and GPL.
* Date: 7/01/2009
* @author Clint Helfers
* @version 1.0.0
*
* http://blindsignals.com/index.php/2009/07/jquery-delay/
*/

$.fn.delay = function( time, name ) {
return this.queue( ( name || "fx" ), function() {
var self = this;
setTimeout(function() { $.dequeue(self); } , time );
});
};
// ***************************
// howto courtesy of JFK
$('a.fancydelay').fancybox({
'overlayShow': false,
// set delay in milliseconds so 5000=5 secs
'callbackOnStart': function(){$("#fancy_outer").delay(5000);}
});
});
</script>

2). add to your <body> tag:
<body onload='$("a.fancydelay").trigger("click");'>

3). insert somewhere into your html code:
<a class="fancydelay" href="images/01.jpg" >open after some seconds</
a>

NOTICE
if you don't want the anchor to appear in your page (only working
onload) just add it a style='display:none;'
also notice that I set overlayShow to false, otherwise the overlay
would be shown for some seconds without the fancybox

MarkDerrick

unread,
Jan 13, 2010, 3:29:38 PM1/13/10
to fancybox
Is there an easy way to do this without needing to add anything to the
Body tag?

Mark.


On Jan 5, 6:11 am, JFK <jfk.d...@gmail.com> wrote:
> ok, ok, ok 3 steps
>
> 1). insert this script somewhere:
> (respect the copyright)
>
> <script type="text/javascript">
> $(document).ready(function() {
> /**
>  * jQuery Delay - A delay function
>  * Copyright (c) 2009 Clint Helfers - chelfers(at)gmail(dot)com |http://blindsignals.com
>  * Dual licensed under MIT and GPL.
>  * Date: 7/01/2009
>  * @author Clint Helfers
>  * @version 1.0.0
>  *

>  *http://blindsignals.com/index.php/2009/07/jquery-delay/

JFK

unread,
Jan 13, 2010, 4:32:40 PM1/13/10
to fancybox
so far I don't see any other way to do it but with onload
if you don't want anything in the body tag you may place onload in
either of the following tags:
<frame>, <frameset>, <iframe>, <img> or <link>
http://www.w3schools.com/jsref/event_onload.asp

something like:
<img src="images/header.jpg" onload='$("a.fancydelay").trigger
("click");' />

MarkDerrick

unread,
Jan 13, 2010, 4:40:01 PM1/13/10
to fancybox
Excellent idea! Thanks very much.
Reply all
Reply to author
Forward
0 new messages