Question: 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 :)

Answer: 
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.com");
          // or any type of script you want to run

    </script>
<?php } ?>

```
For anyone coming 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](https://github.com/colorfulfool/rails-popup), you can do this instead:

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

```