Estoy tratando de abrir una nueva pestaña usando javascript. No funciona y me sale el error:
[Error] SyntaxError: Unexpected token ':'. Expected ')' to end an argument list. (anonymous function)Aquí está mi código:
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();¡Gracias!
Un error de sintaxis. Olvidaste las llaves en el objeto de la línea dos. Debería ser
URL({ string: "https:your.url" });En vez de:
URL(string: "https:your.url");