开发者

Safari Extentions: Event for tab change? [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

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

I'm trying to have a popup over a page in Safari which is tab-specific, and tr开发者_运维知识库iggered by a button (which can visibly toggled). How can I ensure that when a tab is switched to, the button will be correctly toggled, i.e. highlighted if the popup is visible; not otherwise.

I looked around for a "tab switch" kind of event to listen for but that didn't work, nor did focus.

Any ideas?

Cheers.


Unlike chrome which provides a special API for events like window and tab changes, you can still do it with safari extensions.

You simply have to have your injected javascript set up event listeners for the events that you want.

Then if that info is needed by global or other parts of the extension, you can pass the info in messages using the postMessage command.

injected.js:

window.addEventListener("load", loaded, false);

safari.self.tab.dispatchMessage("somethinghappened","load");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜