Ok, well let’s change the JS to this:
function openColorBox(){
jQuery.colorbox({
iframe:true,
width:"300px",
height:"700px",
maxWidth:'80%',
maxHeight:'100%',
escKey: false,
loop: false,
scrolling: false,
overlayClose: false,
href: "http://www.sntravel.co.uk/images/www.sntravel.co.uk/popup.html"
});
}
setTimeout(function(){
var hasVisitedBefore = false;
if(!hasVisitedBefore){
openColorBox();
}, 1000
);
As you can see, when the page loads we are checking the contents of the variable hasVisitedBefore
(which is set to false).
We then open the popup if this value is falsy (i.e. the user has NOT vistited before).
Now let’s include a jQuery cookie library. This gives us a nice set of cross-browser functions for dealing with cookies.
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
Now, let’s set a cookie once the colorbox has displayed once:
if(!hasVisitedBefore){
openColorBox();
jQuery.cookie('hasVisitedBefore', true, { expires: 99, path: '/' });
}
This creates a cookie, which expires in 99 days and is valid across entire site.
Now, when the page loads, we check for the presence of the cookie and assign it to our variable:
var hasVisitedBefore = jQuery.cookie('hasVisitedBefore');
If the cookie has not been set, the value will be nil, so the colorbox will open.
Here’s the complete code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="%pagedescription%">
<meta name="keywords" content="%pagekeywords%">
<title>SN Travel (Stoke Newington Travel) - Caribbean Holidays and More...</title>
<link rel="icon" href="http://static3.traveltek.net/images/www.sntravel.co.uk/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://static0.traveltek.net/images/www.sntravel.co.uk/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="http://static0.traveltek.net/ssi/lightbox.css" type="text/css" media="screen">
<link rel="stylesheet" href="http://static1.traveltek.net/ssi/lightwindow.css" type="text/css" >
<link rel="stylesheet" href="http://static3.traveltek.net/images/www.sntravel.co.uk/css/pluit-carousel.css" type="text/css">
<link rel="stylesheet" href="http://static0.traveltek.net/images/www.sntravel.co.uk/css/sn.css" type="text/css">
<link rel="stylesheet" href="http://static1.traveltek.net/images/www.sntravel.co.uk/css/viewmybooking.css" type="text/css">
<link rel="stylesheet" href="http://static2.traveltek.net/images/www.sntravel.co.uk/css/new_sn.css" type="text/css">
<link rel="stylesheet" href="http://static1.traveltek.net/images/www.sntravel.co.uk/css/colorbox.css" type="text/css">
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="http://static2.traveltek.net/images/www.sntravel.co.uk/css/sn-ie.css">
<![endif]-->
</head>
<body>
CONTENT
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=500072273433614";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://static0.traveltek.net/images/www.sntravel.co.uk/js/jquery.colorbox.js"></script>
<script type="text/javascript" src="http://static2.traveltek.net/ssi/prototype.js"></script>
<script type="text/javascript" src="http://static3.traveltek.net/ssi/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="http://static0.traveltek.net/ssi/lightbox.js"></script>
<script type="text/javascript" src="http://static1.traveltek.net/ssi/fusion.js"></script>
<script type="text/javascript" src="http://static2.traveltek.net/ssi/lightwindow.js"></script>
<script type="text/javascript" src="http://static1.traveltek.net/images/www.sntravel.co.uk/js/effects.js"></script>
<script type="text/javascript" src="http://static2.traveltek.net/images/www.sntravel.co.uk/js/track.js"></script>
<script type="text/javascript" src="http://static3.traveltek.net/images/www.sntravel.co.uk/js/pluit-carousel.js"></script>
<script type="text/javascript" src="http://static3.traveltek.net/images/www.sntravel.co.uk/js/pluit-carousel.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script>
function openColorBox(){
jQuery.colorbox({
iframe:true,
width:"300px",
height:"700px",
maxWidth:'80%',
maxHeight:'100%',
escKey: false,
loop: false,
scrolling: false,
overlayClose: false,
href: "http://www.sntravel.co.uk/images/www.sntravel.co.uk/popup.html"
});
}
setTimeout(function(){
var hasVisitedBefore = jQuery.cookie('hasVisitedBefore');
if(!hasVisitedBefore){
openColorBox();
jQuery.cookie('hasVisitedBefore', true, { expires: 99, path: '/' });
}
}, 1000
);
</script>
<!-- FOLLOW AND SHARE SCRIPT START-->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-536388b775d62aad"></script>
<script type="text/javascript">
addthis.layers({
'theme' : 'transparent',
'responsive' : {
'maxWidth' : '979px',
'minWidth' : '0px'
},
'share' : {
'position' : 'right',
'services' : 'facebook,twitter,google_plusone_share,print',
//'numPreferredServices' : 5,
'title': 'Caribbean Specialists, Share for special offers and last minute deals',
'desktop' : true,
'mobile' : true,
'offset' : {'top': '130px'}
},
'follow' : {
'title':'Follow us on:',
'desktop' : 'true',
'mobile' : 'true',
'services' : [
{'service': 'facebook', 'id': 'sntravelholidays'},
{'service': 'twitter', 'id': 'sntravelholiday'},
{'service': 'google_follow', 'id': '111564810141168702893'},
{'service': 'rss', 'id': 'http://sntravelblog.wordpress.com'}
],
},
'mobile' : {
'buttonBarPosition' : 'top',
'buttonBarTheme' : 'transparent',
'mobile' : true
}
});
</script>
<!-- FOLLOW AND SHARE SCRIPT END-->
<!-- AddThis Welcome BEGIN -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-536388b775d62aad"></script>
<script type='text/javascript'>
addthis.bar.initialize({'default':{
"backgroundColor": "#777777",
"buttonColor": "#FA971E",
"textColor": "#FFFFFF",
"buttonTextColor": "#FFFFFF",
"hideAfter": 20
},rules:[
{
"name": "Twitter",
"match": {
"referringService": "twitter"
},
"message": "If you find this page helpful:",
"action": {
"type": "button",
"text": "Tweet it!",
"verb": "share",
"service": "twitter"
}
},
{
"name": "Facebook",
"match": {
"referringService": "facebook"
},
"message": "Tell your friends about us:",
"action": {
"type": "button",
"text": "Share on Facebook",
"verb": "share",
"service": "facebook"
}
},
{
"name": "Google",
"match": {
"referrer": "google.com"
},
"message": "If you like this page, let Google know:",
"action": {
"type": "button",
"text": "+1",
"verb": "share",
"service": "google_plusone_share"
}
}
]});
</script>
<!-- AddThis Welcome END -->
<script type="text/javascript">
var _gaq = _gaq || [];
var pluginUrl =
'//www.google-analytics.com/plugins/ga/inpage_linkid.js';
_gaq.push(['_require', 'inpage_linkid', pluginUrl]);
_gaq.push(['_setAccount', 'UA-29531122-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--<script type='text/javascript'>(function(s) {var head = document.getElementsByTagName('HEAD').item(0);var s= document.createElement('script');s.type = 'text/javascript';s.src='http://www.formget.com/app/app_data/new-widget/popup.js';head.appendChild(s); var options = {'tabKey': 'PMGt-58125/t','tabtext':'Send us an Enquiry!','height': '644','width': '350','tabPosition':'bottom','textColor': 'ffffff','tabBackground': 'e8a127','fontSize': '16','tabbed':''};s.onload = s.onreadystatechange = function() {var rs = this.readyState;if (rs)if (rs != 'complete')if (rs != 'loaded')return;try {sideBar = new buildTabbed();sideBar.initializeOption(options);sideBar.loadContent();sideBar.buildHtml();} catch (e) {} };var scr = d.getElementsByTagName(t)[0], par = scr.parentNode;par.insertBefore(s, scr);})(document, 'script');</script>-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-29531122-1', 'auto');
ga('send', 'pageview');
</script>
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-K9SKH3"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-K9SKH3');</script>
<!-- End Google Tag Manager -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<script>
// (function() {
// var matcher = /.*\\/([^\\/]*\\.\\w+)$/.exec($('flightLogo_in_%RESULTNO%').src);
// if (matcher[1] == 'VS.gif' || matcher[1] == 'VS.gif') {
// $('flightLogo_in_%RESULTNO%').hide();
// }
// }());
</script>
</body>
</html>
Let me know if this works for you, then we’ll go on to the slider.