+1 vote
by (1k points)
The essence of this. There is a popup that appears after 10 seconds, this problem is not present.
But how to implement it so if the user clicked on the link in this pop-up, it never popup did not appear.
If he rolled the window (clicked on x), give a week, then again. If rolled again, stop.

Can not doperet how to do it

2 Answers

+1 vote
by
Use of cookies.
Make the first test was whether the user clicked the link (like cook isLinkClicked), then clicked on his closure (isCloseButtonClicked). If nothing else, it shows popup. When the user clicks on the close button, then writes the cookie isCloseButtonClicked for 1 week, if on the link, then write isLinkClicked cook for a couple of years.
by (1k points)
Anywhere we can see an example? Can't understand
+1 vote
by
Work through LocalStorage. Start the object in which to store data about the dialog. I was doing so. An example based on the Bootstrap:

<!-- Modal -->

<button class="btn btn-success btn-lg animate-btn" data-toggle="modal" data-target="#myModal">ВЫЗОВИ МАСТЕРА СЕЙЧАС</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Не нашли что искали?</h4>
</div>
<div class="modal-body">
<!-- Тут контент в модальном окне -->
</div>
</div>
</div>
</div>
<script>
// Через сколько событие модал
var limit = 5000;
// Сбросить данные в localStorage через...
var repeat = 300000;

// При переходе на новую страницу проверяем данные и сбрасываем при необходимости
if (Date.now() - localStorage.getItem('count') > repeat) {
localStorage.removeItem('count');
localStorage.removeItem('show');
console.log('Данные в localStorage сброшены');
};

// Если это первое посещение, то запукает отсчет для события модал
if (localStorage.getItem('count') === null && localStorage.getItem('show') === null) {
localStorage.setItem('count', Date.now());
localStorage.setItem('show', 'false');

console.log('Счетчик установлен');

var timer = setInterval( function() {
var time = localStorage.getItem('count');
if (Date.now() - time > limit ) {
console.log('Событие модал');
$('[data-target="#myModal"]').trigger('click');
localStorage.setItem('show', 'false');

clearInterval(timer);
};
}, 500 );
} else {
console.log('Событие модал уже было');
}
</script>
by (1k points)
keslo : Look, thanks
by
Alexander Kotov : but not for that. In my place you would do the same. I hope useful)
by
Alexander Kotov : added code in response
by
Alexander Kotov : a sketch of the ideas here - jsfiddle.net/keslo/3tnkcacz
by (1k points)
Can I see it?
...