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

How to open URL from JS code?

Highlighted
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
Highlighted

Re: How to open URL from JS code?

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

Highlighted

Re: How to open URL from JS code?

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.

Highlighted

Re: How to open URL from JS code?

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

Announcements
Join an
AR Working Group!

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection