javascript - Chrome's prefetching reloads desktop notifications -


i have strange bug when using notifications api in chrome. have page loads notifications cookie , displays them on page load using notifications api. if go second page using hyperlink , start changing url address, moment reach first page's address before hitting enter, notifications popped again. think has how chrome doing clever prefetching. there anyway can stop this?

this code have:

var desktop_notification_options = {   body: text.text(),   icon: this.settings.icon,   tag: text.text() };  var desktop_notification = new notification('', desktop_notification_options);  settimeout(desktop_notification.close.bind(desktop_notification),             this.settings.desktop_notification_timeout); 

i've realized if add alert('') on page, stops (presumably because chrome's prefetch can't skip alert), that's not reasonable fix.

any appreciated.

i found quick fix. checked document.visibilitystate before showing notifications , showed them if set visible. more info here: http://www.w3.org/tr/page-visibility/#dom-document-visibilitystate


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -