Link to home
Start Free TrialLog in
Avatar of sky_revolution
sky_revolution

asked on

JQuery Modal Window OnLoad

I'm using a JQuery script that allows you to initiate a modal window. It currently works by attaching the event to a link (and opens the window when you click the link).

Here is an example below:

My question is: How would I modify this code to open the modal window as soon as the page loads?

<a href="#" id="link-anchor">Show Window</a>
<script language="javascript" type="text/javascript">

$(document).ready(function(){
						   
		$('#link-anchor').live('click',function(e){
			// this is here to position the modal without jumping to the top of the page (because of the "#" href)
			var toppos = $(this).offset(); 	e.preventDefault();
			$.fbmodal({
				modaltop : toppos.top-100,				
				type	: 'info',
				title	: 'Default title',
				text	: 'Text goes here...',
				closeTrigger	: false,
				escClose		: false,
				overlayClose	: false,
				buttons	: [{ //been had objects
						'text' : "Confirm",
						'color'	: "blue",
						'callback'	: function(){ alert("Confirmed"); $.fbmodal.close(); }
					}]
			});
		});
			
});	
</script>

Open in new window


The rest of the code for the modal window and the JQuery lib is included in the document <head> tags.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial