Iphone redirect

pg.security

New Member
Messages
30
Reaction score
0
Points
0
<script type="text/javascript" src="js/webkit_version_xl.js"></script>
...
{literal}
<script language="JavaScript" type="text/javascript">
<!--
var version = get_webkit_version();
var iPhone_regex = /iPhone|iPod/;
var result = version['browser'].search(iPhone_regex);
if (result != -1) {
window.location = "iphoneoptimized.htm";
}
// -->
</script>
{/literal}

are there anythings to make work faster or somethin
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
If you did it in PHP it would certainly be quicker. Try this at the top of your page, the 'header' function must be called before anything else is sent. I haven't tested this though.

PHP:
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
$regex = '/iPhone|iPod/';
if(preg_match($regex, $ua){
header('Location: http://www.example.com/');
}
?>
 
Top