質問

Hi There best collegue,

Currently im busy with developing a bookmarker extension for safari and running up against a problem. How can i acces the current tab url in the popover?

Tnx in advance:)

役に立ちましたか?

解決

The popover doesn't have access to safari.application so can't get the current URL directly, but it can call functions in the global page which can.

In your global page:

function currentUrl() {
    return safari.application.activeBrowserWindow.activeTab.url;
}

Then in the popover:

alert(safari.extension.globalPage.contentWindow.currentUrl());

Ensure that the Access Level is set to 'All' in the Extension builder and secure pages are included otherwise the URL will sometimes be undefined.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top