开发者

ModalBox open on page load

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 automa开发者_StackOverflow社区tically 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.


In js:

if(window.location.search.indexOf('loggedout=true') !== -1) {
    // show your modal   
}

In PHP you can check out: http://www.php.net/manual/en/reserved.variables.server.php $_SERVER['HTTP_REFERER'] to be exact. But note that it can't be trusted.


I achieved my desired result using

<?php
if ($loggedout=="true") { ?>
<body class="slider-header" onload="Modalbox.show('/data/loggedout',{width: 576, title: 'Logged Out'}); return false;">
<?php } else { ?>
<body class="slider-header">
<?php }; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜