Reputation: 1219
I'm using the Colorbox modal pop-up throughout a website, but I want to prevent it from appearing in the following conditions are met:
The following code seems to work OK with I test it in everything except IE8 & 9. I can get the modal to open one time in IE but not again, not even when cache/cookies are cleared and browser is restarted. I don't see any errors in the console. Can anyone help me?
My idea is to show the modal when someone enters the site except if a specified DIV is present on the page or if they have already viewed that page with the DIV.
Thanks in advance for any help.
<script type="text/javascript">
var jQuery_1_8_3 = jQuery.noConflict(true);
jQuery_1_8_3(document).ready(function(){
var emailFormExists = jQuery_1_8_3('#e2ma_signup_form');
if (document.cookie.indexOf('visited=true') == -1 && !(emailFormExists.length)){
var fifteenDays = 1000*60*60*24*15;
var expires = new Date((new Date()).valueOf() + fifteenDays);
document.cookie = "visited=true;expires=" + expires.toUTCString();
jQuery_1_8_3.colorbox({width:"30%", inline:true, href:"#email"});
}
else
{
jQuery_1_8_3('#e2ma_signup_form').length
var fifteenDays = 1000*60*60*24*15;
var expires = new Date((new Date()).valueOf() + fifteenDays);
document.cookie = "visited=true;expires=" + expires.toUTCString();
}
});
</script>
Upvotes: 1
Views: 229
Reputation: 1219
I figured out what the problem was - IE has a setting at the top of the "Delete Browsing History" menu that says "Preserve Favorites Website Data". This box was checked, and when I pulled up the window I just quickly scanned to be sure the cookies option was checked without reading everything else.
I had been using the Cache > Clear Cookies For Domain option in the developer tools to clear the cookies when testing, but I don't think it was working since that option was checked in the browsing history menu and the page I am testing is bookmarked in my favorites.
Feel kinda like a dumbass not having caught that before but maybe I'm not the only one and this can help someone down the road.
Upvotes: 1