cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

How to open URL from JS code?

jmikesell
15-Moonstone

How to open URL from JS code?

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.

3 REPLIES 3

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

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.

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

Top Tags