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

php - Javascript auto popup (without clicking a button) - Stack Overflow

programmeradmin3浏览0评论

I was just wondering if it is possible to display a javascript message (either popup or something nice) which is triggered by something which isn't a mouse click, so for example:

<?php if(a == b) {
    Then auto pop up something
}

I have had a look around and cant seem to find anything, also how do people make like stylistic popups like.. i guess maybe CSS but really fancy ones which cant be done with CSS any ideas?

Thanks a bunch :)

I was just wondering if it is possible to display a javascript message (either popup or something nice) which is triggered by something which isn't a mouse click, so for example:

<?php if(a == b) {
    Then auto pop up something
}

I have had a look around and cant seem to find anything, also how do people make like stylistic popups like.. i guess maybe CSS but really fancy ones which cant be done with CSS any ideas?

Thanks a bunch :)

Share Improve this question asked Feb 15, 2012 at 23:44 Ian TaylorIan Taylor 1791 gold badge5 silver badges18 bronze badges 2
  • 1 Really fancy pop up boxes can most certainly done with CSS. It's just really fancy CSS ;) – Casey Kinsey Commented Feb 15, 2012 at 23:49
  • The really fancy popup boxes are called 'modal dialogs'. Google it! – Calvin Commented Feb 15, 2012 at 23:52
Add a ment  | 

2 Answers 2

Reset to default 2

Just add a script block to open an alert or what ever you need to open

<?php if(a == b) { ?>
    <script>
          alert('hello');
          // or
          window.open("http://wwwstackoverflow.");
          // or any type of script you want to run

    </script>
<?php } ?>

For anyone ing here these days: window.open() called like that will be blocked by any modern browser.

If you're okay with including a third-party script, you can do this instead:

<?php if(a == b) { ?>
  <script>
    Popup("<div>Hello</div>").show('up')
  </script>
<?php } ?>
发布评论

评论列表(0)

  1. 暂无评论