Mukhbir

 
  • Increase font size
  • Default font size
  • Decrease font size
  • default color
  • green color
  • blue color

Detect users browser / specially iphone - ipod and redirect to / load different page

E-mail Print PDF

to detect the users coming from iphone/ipod and then act accordingly.
the code can be altered to detect any other browser too.


js

<script language=javascript>
<!--
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
location.replace("iphone-version.html");
}
-->
</script>

php

<?php
//setting the variables
$ipod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iphone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");

//detecting device
if ($ipod == true || $iphone == true){
header( 'Location: http://site-1/' ) ;
} else {
header( 'Location: http://site-2/' ) ;
}
?>

Comments (0)Add Comment
Write comment
 
  smaller | bigger
 

busy