Use javascript / DOM in Axure Conditions?

I want to set a condition to detect if the user is on an iPhone and navigate to another page of my prototype if they are. My thought was to use Javascript to read navigator.userAgent, but it’s not exposed in the Axure expression builder. Is there a way to use javascript in the conditions in Axure?

I had to do this years ago, maybe RP7 or RP8 timeframe… There were things that had to be done differently for iOS vs Android, block MSIE on desktop, etc. I’ll see if I can find an example. …Couldn’t seem to find any forum posts on this

As I recall, the basic approach is to call your javascript from Axure, have your js code set Axure global variable(s), then in Axure wait a little (like 50-100 ms) to ensure the global variable gets set, trigger an action to test the value of that global variable(s). You can also use javascript to set the text value of widgets, then conditionally test those text values.

For example, you could set up a jump page in Axure–just a blank page with interaction code in the Page Loaded event and at least one other event. Pseudo-code would look like,

PAGE LOADED
Open Link javascript:(insert your js code to get environment vars and set OnLoadVariable value);
Wait 100 ms
Fire Event Page fire Page Click or Tap //just triggering a different event; could be any event

PAGE CLICK OR TAP
If value of OnLoadVariable contains “iOS”
Open Link MyIPhonePage
Else if true
Open Link SomeOtherPage

Note the page doesn’t have to be clicked, you are simply using the Page Click or Tap as a type of function or sub-routine call. In this case it should be triggered and handled long before a user could actually click on the (blank) page, but if it’s a concern you could alternatively place an invisible widget (e.g., a hotspot, rectangle with 0% opacity, a blank dynamic panel) and call one of it’s “non user” events like Moved, Rotated or Panel State Changed)

This kind of “jump page” approach means you can open a link to this page from anywhere in your prototype to test for “iPhone” and handle accordingly. Alternatively, you could keep all your code on whatever buttons or system actions. The trick is to wait for the javascript to set things, then trigger a different event.