searching on the net there are two common ways of achieving this.
My favorite though is in PHP its just so clean? wow. :D
In PHP you can write
<?php
function isIphone($user_agent=NULL) {
if(!isset($user_agent)) {
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
}
return (strpos($user_agent, 'iPhone') !== FALSE);
}
if(isIphone()) {
header('Location: http://www.yourwebsite.com/phone');
exit();
}
// ...THE REST OF YOUR CODE HERE
?>
and in javascript you can write
var agent = navigator.userAgent;
var isIphone = ((agent.indexOf('iPhone') != -1) || (agent.indexOf('iPod') != -1)) ;
if (isIphone) {
window.location.href = 'http://www.yourwebsite.com/phone';
}
Hope that helps.
PK
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…