Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Is there a way to open a tab in a Safari extension using javascript?

I am trying to open up a new tab using javascript. It doesn't work and I get the error:

[Error] SyntaxError: Unexpected token ':'. Expected ')' to end an argument list.
    (anonymous function)

Here is my code:

function openTab() {
    let myUrl = URL(string: "https://google.com")


    // This grabs the active window.
    SFSafariApplication.getActiveWindow { (activeWindow) in

        // Request a new tab on the active window, with the URL we want.
        activeWindow?.openTab(with: myUrl, makeActiveIfPossible: true, completionHandler: {_ in
        })
    }
}

openTab();

Thanks!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A syntax error. You forgot the braces in the object on line two. It should be

URL({ string: "https:your.url" });

Instead of:

URL(string: "https:your.url");
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!