Created
June 24, 2017 09:39
-
-
Save akkord87/5d76f5f71825ea3a2495b912002c0e09 to your computer and use it in GitHub Desktop.
Автоматически открываем Magnific Popup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Подключаем Magnific Popup по стандарту и для открытия модального окна на определенную страницу добавляем HTML | |
$(window).load(function() { | |
setTimeout(function() { | |
$.magnificPopup.open({ | |
items: {src: '#popup-form'},type: 'inline' | |
}); | |
}, 5000); | |
}); | |
// Так же можно использовать куки для того чтоб всплывающее окно отображалось только 1 раз | |
jQuery(window).load(function(){ | |
var now, lastDatePopupShowed; | |
now = new Date(); | |
if (localStorage.getItem('lastDatePopupShowed') !== null) { | |
lastDatePopupShowed = new Date(parseInt(localStorage.getItem('lastDatePopupShowed'))); | |
} | |
if (((now - lastDatePopupShowed) >= (15 * 86400000)) || !lastDatePopupShowed) { | |
jQuery.magnificPopup.open({ | |
items: { src: '#PORRA' }, | |
type: 'inline' | |
}, 0); | |
localStorage.setItem('lastDatePopupShowed', now); | |
} | |
}); | |
jQuery(document).ready(function($) { | |
// А если нужно сделать чтоб оконо показывалось 1 раз и при этом запоминало посетителя то | |
$(window).on('load', function() { | |
var now, lastDatePopupShowed; | |
now = new Date(); | |
if (localStorage.getItem('lastDatePopupShowed') !== null) { | |
lastDatePopupShowed = new Date(parseInt(localStorage.getItem('lastDatePopupShowed'))); | |
} | |
if (((now - lastDatePopupShowed) >= (1 * 1)) || !lastDatePopupShowed) { | |
setTimeout(function(){ | |
$.magnificPopup.open({ | |
items: { src: '#PORRA' }, | |
type: 'inline' | |
}); | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment