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
2 Answers
Reset to default 2Just 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 } ?>