How to get the browser window or active tab url using java script in a safari browser ?
I tried to do it using ->
document.url
window.location.href
But both this solutions are giving me so many urls . I dont know why ?
Also I have searched that safari.application.browserWindow.activeTab gives obj of current active window . But I dont know which methods are provided by activeTab class
If anyone knows , plz help me . Thanks in advance.
If you just want the URL of the "top" document in the current tab, you can use
from within your extension's global page.
The properties and methods of the SafariBrowserTab class are given here: https://developer.apple.com/library/safari/#documentation/UserExperience/Reference/SBrowserTabClassReference/SafariBrowserTab.html#//apple_ref/doc/uid/TP40009793
I infer from your question that your extension is using an injected script, which is reporting the URL of the page in which it is being run to the global page. Your global page is receiving multiple URLs because the injected script is running not only in the "top" document of the tab, but also in every iframed document inside it.
If you want to prevent the injected script from running inside iframes, wrap the code in a statement like this: