Monday, 15 September 2014

javascript - In a Safari extension, how do I validate that the open page is a file of a certain format? -



javascript - In a Safari extension, how do I validate that the open page is a file of a certain format? -

i new html/js , i'm making safari extension first time. want enable toolbar button when current page has .gif open. how write validate function this?

also, "validate" event fired every time page reloads? there other triggers it?

you can't sure content of current page gif, can check whether url of current tab ends ".gif". in global page script, utilize safari.application.activebrowserwindow.activetab.url current url.

in addition, can utilize injected script inspect dom of page. in safari, if document's body has single node, , node <img>, resource located @ tab's url image. utilize document.body.childnodes check body contents.

validate events happen whenever safari thinks might want update extension element (like toolbar button). includes when tab opened, closed, focused, or blurred; when url changed; , when contents reloaded. btw, tab focus , blur happens when safari focused or blurred, not when switch tabs.

javascript html safari-extension

No comments:

Post a Comment