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

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -