Safari 5 Extension: How can I detect when a window's current tab has changed?

前端 未结 8 1550
青春惊慌失措
青春惊慌失措 2021-01-03 13:17

I have a Safari 5 extension that contains a toolbar. Whenever the current tab changes, that toolbar should be updated. I would like to do something like this from my bar\'s

8条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 14:00

    This code will help to trace the change in URL :- Write this code Inject.js , in side function

    
    function trackURL() {
    
        alert("beforeNavigate "+safari.application.activeBrowserWindow.activeTab.url);
            setTimeout(function() {
                alert("afterNavigate "+safari.application.activeBrowserWindow.activeTab.url);
    
                }, 500);
        }
        safari.application.addEventListener("beforeNavigate", trackURL, true);
    

提交回复
热议问题