jquery - Javascript - Open Popup automatically on page load - Stack Overflow

Im using the reveal popup and its working fine when I click on the link to open it. However, what I am

Im using the reveal popup and its working fine when I click on the link to open it. However, what I am trying to do now is to open automatically on open the page (pageload).

How can I achieve this?

here is my code so far:

<a href="#" data-reveal-id="myModal">open poup</a>    

<div id="myModal" class="reveal-modal">
...something....
</div> 


 $(function () {
        $(window).bind('load',
            function (e) {
                $('#myModal')
            });
    });

I have tried it with javascript with page load, window load etc.. but nothing is working

Im using the reveal popup and its working fine when I click on the link to open it. However, what I am trying to do now is to open automatically on open the page (pageload).

How can I achieve this?

here is my code so far:

<a href="#" data-reveal-id="myModal">open poup</a>    

<div id="myModal" class="reveal-modal">
...something....
</div> 


 $(function () {
        $(window).bind('load',
            function (e) {
                $('#myModal')
            });
    });

I have tried it with javascript with page load, window load etc.. but nothing is working

Share Improve this question edited Sep 26, 2013 at 11:10 Richard Tingle 17.3k5 gold badges57 silver badges80 bronze badges asked Sep 25, 2013 at 15:24 user2232273user2232273 4,97416 gold badges51 silver badges76 bronze badges 3
  • 2 You should edit your question and post the javascript part. – TCHdvlp Commented Sep 25, 2013 at 15:25
  • 1 Can you add some of your Javascript so we can debug? – Barrie Reader Commented Sep 25, 2013 at 15:25
  • 5 Purely from a usability perspective, please don't do this. It's a horrible way to use a site, and I for one adblock these kind of things anyway – Bojangles Commented Sep 25, 2013 at 15:25
Add a ment  | 

3 Answers 3

Reset to default 3

Put the function in:

A $( document ).ready() block.

$( document ).ready(function() {

// Do here...
});

Or either:

$( window ).load(function() {
    console.log( "window loaded" );
});
<body onload="javascript:yourNastyUglyPopupFunction()">

is this working? If not then your function is not properly defined or your pop-up is blocked by adBlock or browser itself.

You could try using < body onload="javascript function to run" >

Most UI libraries, like JQuery, also allow you to run functions upon document load.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744367349a4570771.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信