// Broadcast that you're opening a page. localStorage.openpages = Date.now(); var onLocalStorageEvent = function(e){ if(e.key == "openpages"){ // Listen if anybody else is opening the same page! localStorage.page_available = Date.now(); } if(e.key == "page_available"){ alert("您已在其他分頁開啟過此頁面"); return false; } }; window.addEventListener('storage', onLocalStorageEvent, false);以上的方法在chrome、firefox等瀏覽器上皆可正常運作,但是在safari上會有問題,警告會在第一個分頁就跳出
目前有被回報為safari的bug -> Storage events are fired for the same tab
沒有留言:
張貼留言