I need a script that only allow users with an Ipad to view my site. I need it to display a message saying the browser is not compatible and this site needs to be viewed with your Ipad. I am a total newbee at these forums and programming so go easy on me.
try this.. if(!/iPad/i.test(navigator.userAgent)) { alert("Sorry, this site can only be viewed by in iPad."); window.location = 'http://www.google.com/'; // redirect them some where } Code (markup):
Is that going in my header.php or index.php file. I'm using a wordpress template. I added it in but it just displays the code you gave. I know for sure I'm doing it wrong and your code works. <?php /** * @package WordPress * @subpackage Default_Theme */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <head profile="http://gmpg.org/xfn/11"> if(!/iPad/i.test(navigator.userAgent)) { alert("Sorry, this site can only be viewed by in iPad."); window.location = 'http://www.mysite.com/'; // redirect them some where }
it javascript, you can put it before </head> here's the exact code.. <script type="text/javascript"> if(!/iPad/i.test(navigator.userAgent)) { alert("Sorry, this site can only be viewed by in iPad."); window.location = 'http://www.google.com/'; // redirect them some where } </script> HTML: