Skip to content

Instantly share code, notes, and snippets.

@akkord87
Created June 24, 2017 09:39
Show Gist options
  • Save akkord87/5d76f5f71825ea3a2495b912002c0e09 to your computer and use it in GitHub Desktop.
Save akkord87/5d76f5f71825ea3a2495b912002c0e09 to your computer and use it in GitHub Desktop.
Автоматически открываем Magnific Popup
// Подключаем 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