I am using ModalBox (http://okonet.ru/projects/modalbox/index.html) on my website. It is set up and works fine, but I would like to make it open on page load in certain circumstances. In particular, I would like to have it open with a message when users log out. Right now when users log out, it goes to my homepage with a message in the page (I do this by loading index.php?loggedout=true when users log out and have the text show when the variable is true. Using this method (having ?loggedout=true) but loading with a ModalBox open instead of just text in the page body. Alternatively, if it could detect what page it came from without the variable and open then, that would be nice too.
tl;dr: How can I have a ModalBox open automatically on page load.
Edit: I tried putting
<script type="text/javascript">
if(window.location.search.indexOf('loggedout=true') !== -1) {
Modalbox.show('/data/loggedout',{width: 576, title: 'Logged Out'}); return false;
}
</script>
On my page, but that didn’t work.
I achieved my desired result using