Kill session on popup close until the closing of browser
I want to show a popup about browser compatibility to the users visiting my website. I have used the popup in about 5 pages and it would be annoying for the users to see the same popup for more than once when they visit my website. So I am thinking to use a session and kill it when the user closes the poup. IT should not be shown until the browser is restarted. Could s开发者_运维百科omeone tell me how it can be done. I know what can be done but not how? Thanks a lot inadvance!!
1) Definitely spend your time fixing the browser compatibility instead of learning how to control your popups.
2) Create a tiny cookie using plain javascript (or jquery wrapper) and store bc_notice=1
. Then retrieve that cookie and if it's already set to 1 - don't show the popup.
If you really have to do that, place a cookie that will persist during browser's lifetime. If it doesn't exist, make one that says "A popup windows should be shown". After it's shown, modify that cookie using Javascript so it says "Ok, window shown, now I won't be used anymore".
I'm assuming by "pop-up" you mean something similar to the CNN edition selector that slides down from the top or like the SO "a new answer has been posted to this page" bar at the top of this page. An actual javascript window popup would be incredibly intrusive for something like this.
Show the message once. Once it is shown, store its status in a persistent cookie and never show it again. As an alternative, provide an X somewhere so the user can get rid of it and determine never to see it again. They don't want to see it in the first place, but if you have to show it... whatever.
Mostly - fix your issues. Don't spend time worrying about fancy ways to avoid fixing them.
<html>
<head>
<title></title>
<script language="javascript">
function setFlag()
{
// Call Web Service or Ajax Method with your session Key
// CallaMethod('ScreenDisplayed');
}
</script>
</head>
<body onbeforeunload="setFlag();">
</body>
</html>
精彩评论