开发者

How to show a popup through javascript just on the first page load of the session?

we would like to show a popup advertising of an iphone app on 开发者_运维问答our website to users that browse with the applo mobile devices.

We already achieve it, but now we need to show only on the first page load of the user session, so it wouldn't be disruptive on every page load.

Any idea? Thanks in advance!


Set a cookie and only show the popup is this cookie does not exist.


Why not use a cookie? Do something like

if(!isset($_COOKIE['firstVisit'])){
    //Show popup (maybe echo some JS)

    $inTwoMonths = 60 * 60 * 24 * 60 + time(); 
    setcookie('firstVisit', 'blah', $inTwoMonths); 
}else {
    //Do nothing
}


There are two ways in which you can do this:

(1) Add a variable in the session itself which indicates as to whether the pop-up should be displayed or not.

(2) Alternatively, as suggested you could set a cookie and take appropriate step depending upon the cookie value.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜