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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

How to open URL from JS code?

jmikesell
16-Pearl

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.

kornelius
14-Alexandrite
(To:jmikesell)

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

Announcements

Top Tags