iPhone 2.0 Safari Glitch – UPDATED Detect and Redirection Script Solution

iphone 2.0 detectionThanks to a user of the iPhone template, a glitch in the newest safari that throws some bugs into the detection script.

First off – credit to who deserves it. Chris Bailey started BoatingBay.com in 2006 and was also the first boat classifieds on the iPhone – the mobile version is pretty nice. Check out used boat classifieds to search for boats. Be sure to check it out on the iPhone to see how he’s worked it out.

Anyway, the previous script (read more about the implementation, it’s still the same and for comments) worked perfectly until Apple updated Safari. Now, if the script is used to detect an iPhone, the “back” navigational button in the web app functioned as a Browser back button. ARG! Chris rewrote the script and sent it to me and it’s a good one. Anyone using the Template with the detection script should update their site.

Below is the updated script.

<script language=javascript>
<!–
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
location.href=’YOURMOBILESITE.html';
}
–>
</script>

Thanks Chris! and nice mobile search for used boats function!

 

UPDATE:

If  you are running WordPress then use this plugin, much easier.