Detect Device and Redirect

I am trying to detect the device and redirect if the user-agent contains iPhone

<body is="dmx-app" dmx-on:load="Browser1.userAgent.contains(\'iPhone\') ? Browser1.goto('https://myurl.com/denied/'+query.key+'') : false">

I have tried a Flow but that doesnt seem to work either.
Any help would be appreciated

I don’t know if it matters or not, but what server type are you using? (i.e. nodejs, php, asp, etc.)

I haven’t done anything with user agents before, so I really am not able to help out, but the server type might help others when answering you.

Hi @scott
NodeJS,
I can detect and display the details OK

Are you seeing any error in console with this code?
Also, can you try to put in a simple Browser1.alert(Browser1.userAgent) to check if this part of the data is accessible on load event or not.

If it works fine, maybe try this:

<body is="dmx-app" dmx-on:load="Browser1.userAgent.contains('iPhone') ? Browser1.goto('https://myurl.com/denied/'+query.key) : ''">
2 Likes

Brilliant @sid
Much appreciated

Did that work?

Yes it did, thank you.

1 Like