Skip to main content
1-Visitor
August 6, 2018
Question

How to open URL from JS code?

  • August 6, 2018
  • 2 replies
  • 3159 views

Does anyone know how to open a URL via JS? I have tried window.open() which works in the Preview and on Android but not iOS.

2 replies

18-Opal
August 7, 2018

I've struggled with this too. One workaround I've found, which relies on a confirmation popup:

 

  • Create a popup version of a confirmation dialog
  • Instead of an OK button, put a Hyperlink widget on the dialog, but style it to look like an OK button
  • When you want to follow the link:
    • Show the popup
    • Set the link target using JS
  • User clicks the OK "button", which is really a Hyperlink, and navigates to the target location

--Clay

jmikesell1-VisitorAuthor
1-Visitor
August 7, 2018

Yeah that's what I arrived at as a workaround. The bit of internet research i did seems to point to a "feature" in Safari on iOS that does not allow a window.open action unless it originates from a click. So where Android/Chrome and IE will allow JS to invoke window.open directly Safari will not.

5-Regular Member
March 27, 2019

window.location = "myURL" solves the issue on iOS. It opens a new browser tab in Safari.