0

I want to build a small Safari extension for personal use. I read some tutorials about it and now my first goal is to open the current website in a new tab. The script opens a new tab, but unfortunately it doesn't open the current website.

This is the file global.html:

<!DOCTYPE HTML>

<script>
safari.application.addEventListener("command", performCommand, false);

function performCommand(event) {
    var currentURL = safari.application.activeBrowserWindow.activeTab.url;

    if (event.command == "testExtension") {
        var newTab = safari.application.activeBrowserWindow.openTab();
        newTab.url = currentURL;
    }
}
</script>

If I change

newTab.url = currentURL;

to

newTab.url = "www.examplewebsite.com";

everything works fine.

So I assume that the variable currentURL is the problem.

Thank you for your help!

Stefan
  • 11
  • 2

0 Answers0