December 12th, 2012, 07:00 AM
What I need to do now, is that if someone goes to the "_iPad.asp" page and they are not on an ipad or iphone, it will redirect them to the regular page.
if (navigator.userAgent && ( navigator.userAgent.indexOf("Pad") > -1 || navigator.userAgent.indexOf("iPhone") > -1 ))
So, I placed a sniffer in the "_iPad.asp" page, that should redirect to the regular page, if the view isn't on an iPad or iPhone. The code, which doesn't work, looks like this:
I just don't want people viewing the iPad page on a desktop computer. So, if by some chance they're on a desktop, and pull up the "_iPad.asp" page, they should be redirected to the regular page.
if (navigator.userAgent && ( navigator.userAgent.indexOf("Pad") < -1 || navigator.userAgent.indexOf("iPhone") < -1 ))
Can anyone tell me the correct syntax for the 2nd bit of code?
Last edited by lelales; December 12th, 2012 at 11:54 AM.
December 12th, 2012, 01:33 PM
indexOf returns -1 exactly when the value isn't found; you're comparing it to < -1, but -1 is not less than -1, so the condition is false.
I'm assuming you know this already, but someone could view the ipad page on a desktop just by changing their user agent.
December 12th, 2012, 01:41 PM
I did not know the return value, so I was just guessing. This should be helpful.
The thing I am doing is that, if you are not on and iPad and you go to the iPad version of the page, you will be redirected to the non ipad version.
And vice versa. If you are on an ipad, and go to the non iPad version, you will be redirected tot he iPad version.
A little convoluted, but this seemed to be the best way to go about it.
thanks for your help!!