1

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

Rudi
  • 75
  • 1
  • 1
  • 4

2 Answers2

4

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>
Sergey Eremin
  • 10,994
  • 2
  • 38
  • 44
  • 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 Jun 24 '10 at 10:37
  • jquery.com, more specifically - http://plugins.jquery.com/files/jquery.cookie.js.txt. save it as js... – Sergey Eremin Jun 24 '10 at 10:46
  • It Works perfectly.. Now.. how to set the expired cookies? – Rudi Jun 24 '10 at 11:03
  • 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 – Sergey Eremin Jun 24 '10 at 11:29
0

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: 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.

Community
  • 1
  • 1
RobertPitt
  • 56,863
  • 21
  • 114
  • 161