Launch Fancybox automatically

Fancybox currently does not directly support a way to automatically launch. The work around I was able to get working is creating a hidden anchor tag and triggering it’s onclick event. Make sure your call to trigger the onclick event is included after the jquery and fancybox js files are included. The code I used is as follows:

This sample script is embedded directly in the html, but it could also be included in a js file.

<pre><code><script type="text/javascript">
    $(document).ready(function() {
        $("#hidden_link").fancybox().trigger('click');
    });
</script></code>

Share this

The Author

admin - Hello, my name is Simon, I’am 25 and I’m a software and web developer. My interests span all aspects of programming and development, including ASP, JavaScript, AJAX, PHP, .NET, Java, C#, C++, Objectv-C, Flash, Cocoa, SQL, XML and everything in between. www.simra.ch

Leave a Reply

*
 
© 2010 onYou GmbH. All Rights Reserved