What's new

Web Device Detection Script [Websites]

  • Thread starter Jack The Stripper
  • Start date
  • Views 412
Status
Not open for further replies.
Jack The Stripper

NLx MODDERS

Snap? Crackle? Pop?
Messages
608
Reaction score
92
Just A little something i wrote awhile back to detect what device is being used and Ex: Iphone, Ipad, Ipod..... can be used for sending to mobile site or something else anyways here you go

HTML:
<html>
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body onload="DetectAll()">
<body>
<p>Website Detection Page <b>Current Device???</b> </p>
</body>
 
 
<script type="text/javascript">
//KEEP THIS HERE!
//Completely Coded By ClaytonMx
//Only Use The DetectAll() Fuction
 
var deviceIphone = "iphone";
var deviceIpod = "ipod";
var deviceIpad = "ipad"
 
//Sets To Lower Case
var uagent = navigator.userAgent.toLowerCase();
 
//Detects if Iphone?
function DetectIphone()
{
  if (uagent.search(deviceIphone) > -1)
    return true;
  else
      return false;
}
 
//Detects Ipod?
function DetectIpod()
{
  if (uagent.search(deviceIpod) > -1)
      return true;
  else
      return false;
}
 
//This Is the Only fucntion Needed!
function DetectAll()
{
    if (DetectIphone())
      alert('Device Is an Iphone');
    else if (DetectIpod())
      alert('Device Is an Ipod');
    else if (DetectIpad())
    alert('Device Is an Ipad');
}
 
//Detects Ipad?
function DetectIpad()
{
    if (uagent.search(deviceIpad) > -1)
    return true;
    else
    return false;
 
}
</script>
 
</html>

some reson the **** behind detect all at the top is an on load command but it stars it out for some reason?
 
Status
Not open for further replies.
Top Bottom