Leeloo
Leeloo

Reputation: 111

Execute jQuery Popup When Page Loads?

I'm using the Reveal modal plugin by Zurb.

http://www.zurb.com/playground/reveal-modal-plugin

Does anybody know how I can get the modal to execute (as in open the popup box) when my page has finished loading as opposed to when the handler is clicked?

I'd like to use it to display a simple message each time somebody opens my homepage.

I've dug through the code and tried a few things, but I'm a self confessed jQuery noob.

I was going to post the entire contents of the jQuery plugin itself, but it might just be easier to download it and take a look for yourself.

Thanks!

:)

Upvotes: 1

Views: 7193

Answers (4)

user2363002
user2363002

Reputation: 11

Hey had trouble getting this to work on a page using other .js libraries where JQuery NoConflict was being used -- in that case try this:

jQuery(document).ready(function($) { $('#myModal').reveal(); });

Upvotes: 1

Developer
Developer

Reputation: 2006

Something like this should work:

<script type="text/javascript">
$(document).ready(function() {
  $('#myModal').reveal();
});
</script>

Upvotes: 1

j08691
j08691

Reputation: 207861

Couldn't you just do the following after you instantiate your modal:

$(document).ready(function() {
    // instantiate modal first
    $('#myModal').reveal();
});

Upvotes: 1

Gabe
Gabe

Reputation: 50475

$(function() {
    $('#myModal').reveal();
});

OR

$(document).ready(function() {
    $('#myModal').reveal();
});

Upvotes: 3

Related Questions