I am looking for a way to detect if a page is visited by an iPhone.
What I'm basically looking for is for a way to stop all but iPhone from viewing a specific web page.
Something like...
If Browser !=iPhone then exit;
Is this possible using Javascript?
if (navigator.userAgent.toLowerCase().indexOf("iphone") ==-1)
location.replace("goaway.html");
if(navigator.userAgent.match(/iPhone/i)) {
...
}
Though i would recommend you to do that before the DOM is loaded, e.g. with PHP:
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone')) {
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With