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 :)
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 , you can do this instead:
<?php if(a == b) { ?>
<script>
Popup("<div>Hello</div>").show('up')
</script>
<?php } ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.