Jump to content

[SOLVED] Detecting iPhone users


simonp

Recommended Posts

Hi,

 

I'm using this code to detect iPhone users to my website and then redirect them to their dedicated pages:

 

if ((navigator.userAgent.indexOf('iPhone') != -1) ||   
(navigator.userAgent.indexOf('iPod') != -1)) {   
document.location = "http://www.xxx.com/iphone/";   
}  

 

But at the bottom of the iPhone site I want to offer a link back to the main site should they wish to view that rather than the dedicated iPhone site.

 

I've seen it done like http://xxx.com/?noiphone which will then stop the redirect - but how might I include that in the javascript above?

 

Thanks

 

Simon

Link to comment
https://forums.phpfreaks.com/topic/175715-solved-detecting-iphone-users/
Share on other sites

untested but should atleate give you an idea

if ( window.location.href.indexOf("noiphone") == -1 ){
if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
		document.location = "http://www.xxx.com/iphone/";   
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.