...

View Full Version : quick cookie question



emericana
07-22-2011, 07:03 PM
using jquery and cookie plugin.

i made a popup window. when the user clicks on a check box the window closes, forwards them to a new page, and then sets a cookie.

i need it so that when they go back to the original page (where the popup came from) if the browser detects the cookie then the popup does not occur. I do not know why this does not work because when I alert the value of the cookie out, it gives me the correct number. something must be wrong in my logic ?
code on the base page.


<script type="text/javascript">
var test123 = $.cookie('FBCheck');

if ( test123 != 1212){
function popup(Site)
{
window.open(Site,'PopupName','toolbar=no,statusbar=no, location=no,scrollbars=no,resizable=no,width=350,height=500')
}
}

</script>


code on popup (both files are in same directory)


$(document).ready(function() {
$("#Cbox").click(function() {
window.open ("http://www.google.com", "Google");
window.close();
$.cookie('FBCheck', '1212', {expires: 365, path: '/'});



});
});


The jquery source is installed as is the plugin.

Thanks so much for your help in advance!

devnull69
07-22-2011, 11:57 PM
if ( test123 != 1212){
function popup(Site)
{
window.open(Site, 'PopupName', 'toolbar=no, statusbar=no, location=no, scrollbars=no, resizable=no, width=350, height=500')
}
}

What do you want to achieve with that code? Define the function only if test123 (which is a string) doesn't equal the numeric value 1212? Definitely not ...

You wanted to OPEN the popup only if the cookie isn't set to "1212", so this is what you wanted to do


if ( test123 != "1212"){
window.open(Site, 'PopupName', 'toolbar=no, statusbar=no, location=no, scrollbars=no, resizable=no, width=350, height=500')
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum