views:

38

answers:

2

Hi all, I have a site using javascript popup effect like this:

<script type="text/javascript">
     var GB_ROOT_DIR = "greybox/";
</script>
<script src="greybox/AJS.js" type="text/javascript"></script>
<script src="greybox/AJS_fx.js" type="text/javascript"></script>
<script src="greybox/gb_scripts.js" type="text/javascript"></script>
<link href="greybox/gb_styles.css" type="text/css" rel="stylesheet">
<script language="JAVASCRIPT">

function loadWindow(){
  GB_showCenter('Free Report!', 'http://www.signupformlocation.com/popup/signup.php', 420, 570);
}

window.onload = loadWindow;

     </script>

But everytime my visitor go to the homepage, my popup always shown. How to do making this popup only display one time?

Please Help me

+3  A: 

you can use cookies and jquery

<script src="js/jquery.cookie.js" type="text/javascript"></script>
<script>
function loadWindow() {
    if ($.cookie('popup_flag') != 'true') {
        GB_showCenter('Free Report!', 'http://www.signupformlocation.com/popup/signup.php', 420, 570);
        $.cookie('popup_flag', 'true');
    }
}
</script>
kgb
Hi kgb, thanks for your answer...Bytheway.. how to get js/jquery.cookie.js? where to download this files and add to my server?Thanks Before
Rudi
jquery.com, more specifically - http://plugins.jquery.com/files/jquery.cookie.js.txt. save it as js...
kgb
It Works perfectly..Now.. how to set the expired cookies?
Rudi
what do tou mean "expired"? how to set expiration time? here is the full syntax... $.cookie("the_cookie", "the_value", {expires: 7, path: "/", domain: "jquery.com", secure: true}); ...that would be 7 days
kgb
A: 

Personally i would go with JStorage, its a HTML5 jQuery Plug-in the uses the local storage on most popular browsers.

Example:

var loadWindows = function()
{
    if(!$.jSotreage.get('welcome_flag'))
    {
        GB_ShowCentre('Free Support!') // Blah
        $.jStorage.set('welcome_flag',true);
    }
}

Uses JSON To serialize all data in the local storage:-

jStorage: http://plugins.jquery.com/project/jStorage

Draft: http://dev.w3.org/html5/webstorage/

Without jQuery: http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage

You can store around 5MB Per domain so this would be benificial and should take over the use of cookies within the javascript environment.

RobertPitt