Automatically call jquery function (fancybox) when page loads

Experts,

Im having difficulty trying to get a fancybox function to start when the page loads. I have reviewed the guides on the host website but cant get it to work...

http://www.suremedia.co.uk/aegis.php
(as you can see i have tried simulating the click event but it doesnt initiate the function)

Any suggestions would be greatly appreciated

Regards
Easynow
LVL 12
Dean OBrienAsked:
Who is Participating?
 
WebDevEMCommented:
Hi... I have a JSFiddle set up for that at http://jsfiddle.net/webdevem/5EV8r/ if you want to take a look.  What I did was create a link with no content (so it can't be seen) and simulate the click on that.

<a class="fancyTrigger" href="#TheFancybox"></a>
<hr>
<div id="TheFancybox"></div>

Powered by <a href="http://fancybox.net/" target="_blank">Fancybox</a>
¿

$(".fancyTrigger").fancybox();
$(".fancyTrigger").trigger('click');¿

Open in new window

0
 
Dean OBrienAuthor Commented:
Hi Webdevem

I have tried that but for some reason its not working. Can you see whats wrong with the following?

<a href="#inline" class="various yellow" id="form-caller">here</a>

$(document).ready(function() {
	$(".various").fancybox({
		maxWidth	: 900,
		maxHeight	: 900,
		fitToView	: true,
		width		: '50%',
		height		: '50%',
		autoSize	: true,
		closeClick	: false,
		openEffect	: 'none',
		closeEffect	: 'none'
	});


});
$(".various").trigger('click');

Open in new window


Thanks
Easynow
0
 
Dean OBrienAuthor Commented:
never mind that, i had the trigger function out side the ready function...

Im sure i might have looked at your jsFiddle when messing earlier...

Thanks
Easynow
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
WebDevEMCommented:
I just found that site recently, and love it for testing things out... I even post examples on code I post on my jQuery blog.  (Still in its infancy, but it's a good start.  http://juntangled.blogspot.com/)

So everything's working now?
0
 
Dean OBrienAuthor Commented:
Yeh its working now.

The auto start was in fact for the page that is displayed after the form is sent. Otherwise the success/fail message was not being show to the user.

Thanks for help

Easynow
0
 
Dean OBrienAuthor Commented:
Sorry for delay
Easynow
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.