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

前端 未结 8 1620
青春惊慌失措
青春惊慌失措 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:19

    That's the event you are looking for. I'm not sure, but i think is a new addition to the extensions api. You can put in global.html or in the popover.html

    safari.application.addEventListener("activate", activateHandler, true);
    
    function activateHandler(event) {
        safari.application.activeBrowserWindow.activeTab.page.dispatchMessage('someId', false);
    }
    

提交回复
热议问题