this is what is used 开发者_如何学Goto load fancybox on page load. However, I want this to be appeared on new visitors or people who visited the page 3 days ago.
I guess with a jQuery cookie but I don't know how.
jQuery(document).ready(function() {
$.fancybox(
'<h2>Hi!</h2><p>Lorem ipsum dolor</p>',
{
'autoDimensions' : false,
'width' : 350,
'height' : 'auto',
'transitionIn' : 'none',
'transitionOut' : 'none'
}
);
});
In your <head>
add <script src="jquery.cookie.js"></script>
, then:
$(function() {
if ($.cookie('mycookie')) {
// it hasn't been three days yet
} else {
$.fancybox(
'<h2>Hi!</h2><p>Lorem ipsum dolor</p>',
{
'autoDimensions' : false,
'width' : 350,
'height' : 'auto',
'transitionIn' : 'none',
'transitionOut' : 'none'
}
);
}
});
// set cookie to expire in 3 days
$.cookie('mycookie', 'true', { expires: 3});
This uses the cookie plugin.
See Can jQuery read/write cookies to a browser?
I have read this and tried to incorporate this to my website but its not working.
In my 'theme.liquid'
Under ''
I have this:
<script src="jquery.cookie.js"></script>
In my 'jquery.cookies.js'
I have:
$(function() {
if ($.cookie('mycookie')) {
} else {
$.fancybox(
'<script src="//setup.shopapps.io/social-login/script/snookieshop.js?width=300&height=330"></script>'
,
{
'autoDimensions' : true,
'width' : 350,
'height' : 'auto',
'transitionIn' : 'none',
'transitionOut' : 'none'
}
);
}
});
$.cookie('mycookie', 'true', { expires: 1});
The reason why I have this Script is because I am using a app from Shopify and this is the line of code they gave me for a sign up with social media.
<script src="//setup.shopapps.io/social-login/script/snookieshop.js?width=300&height=330"></script>
The purpose of doing this is because I want the pop-up screen to appear on the homepage whenever a customer comes in and visits.
精彩评论