Auto Close Fancybox

Parent Page Code (from where fancybox script is called)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<script type="text/javascript" >
 $().ready(function(){  
'hideOnContentClick': true,'callbackOnShow': autoClose });
  $("a.uploadVideo").fancybox({'frameWidth': 400, 'frameHeight':160});
 });
 
 < /script>
 
< script type="text/javascript" src="http://localhost/test/jscripts/jquery.js">< /script>
< script type="text/javascript" src="http://localhost/test/jscripts/jquery.fancybox/jquery.fancybox-1.2.1.pack.js">< /script>
 
 <  script >
  function triggerClose(){
   var el = $("#fancyCloseId");
   el.bind("click", $.fn.fancybox.close);
   el.trigger('click'); 
  }
 
  function autoClose(){
   setTimeout("triggerClose()",1000);
  }
 < /script>
 
 
< body >
  < a class="iframe uploadVideo" href="iframepage.html?ie=UTF-8&aid=video">Video< /a>
 
  < div id="fancyCloseId">< /div
 
< /body >

iframepage.html page
———————–

1
2
3
4
5
6
7
8
9
10
11
12
13
14
< script type="text/javascript" src="http://localhost/test/jscripts/jquery.js"><  /script>
< script type="text/javascript" src="http://localhost/test/jscripts/jquery.fancybox/jquery.fancybox-1.2.1.pack.js">< /script>
 
< body >
 ...........message here........
< /body>
 
$(function(){ 
   if(typeof(parent.autoClose)=="function"){ 
     parent.autoClose();
   }
   else {alert("Function not found")};
});
</script>

5 thoughts on “Auto Close Fancybox

  1. 191

    I am looking for a function that will automatically open an image when the main web page loads. I got that to work. Now I need a function to automatically close the image after a second or 2 without user interaction. Please send contact info and I will send you the code I am using. The code you posted looks like it is for version 1.2.1 and I use 1.3.1. Thank you Jerry

  2. 199

    I’m sorry for this delay writing. But anyway you can reach me through skype: anunay
    or you can mail me at ‘anunay.dahal@live.com’

    Thank you

  3. 200

    I think there is a mistake with my Skype ID:

    here is the correct one:
    anunay.dahal

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam protection by WP Captcha-Free