Jump to content

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/";   
}
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.