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!
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");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.