views:

84

answers:

2

Hi, How do I make this SimpleModal script to load when the page loaded instead of clicking the button? Thank You =)

< div id='basic-modal' >

<a href='#' class='basic'>Demo</a>
</div>

Basic Modal Dialog

For this demo, SimpleModal is using this "hidden" data for its content. You can also populate the modal dialog with standard HTML or with DOM element(s).

Examples:

$('#basicModalContent').modal(); // jQuery object; this demo

$.modal(document.getElementById('basicModalContent')); // DOM

$.modal('<p><b>HTML</b> elements</p>'); // HTML

    </div>




    <!-- preload the images -->
    <div style='display:none'>
        <img src='img/basic/x.png' alt='' />
    </div>
</div>
+2  A: 

jQuery offers the .ready() handler which fires when the browser DOM content was loaded.

$(document).ready(function(){
    // code which executes on dom ready
});

short cut for this

$(function(){
});

There are several other ways/handlers. You could also deal with the window onload event, which fires if all content is loaded completly (images, iframes, etc.)

window.onload = function(){
     alert('onload! yay!');
};

jQuery'ish

$(window).load(function(){
    alert('onload! yay!');
});
jAndy
A: 

Just put your code on load event of the window like this:

$(window).load(function(){
  $('#basicModalContent').modal();
});
Sarfraz