最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Execute jQuery Popup When Page Loads? - Stack Overflow

programmeradmin0浏览0评论

I'm using the Reveal modal plugin by Zurb.

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!

:)

I'm using the Reveal modal plugin by Zurb.

http://www.zurb./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!

:)

Share Improve this question asked Apr 23, 2012 at 19:47 LeelooLeeloo 1111 gold badge4 silver badges12 bronze badges 1
  • Did you try putting it in $(document).ready(...)? – jlaceda Commented Apr 23, 2012 at 19:50
Add a ment  | 

4 Answers 4

Reset to default 3
$(function() {
    $('#myModal').reveal();
});

OR

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

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

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

Something like this should work:

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

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(); });

发布评论

评论列表(0)

  1. 暂无评论