I’m using mdetect.js as obtained from mobileesp.com. The file looks perfect for what I need, and I’ve saved it locally. Then on my HTML page, I want to call one of the functions and if it returns true (i.e. user is on mobile device) display a table at the top of the page saying our site doesn’t support mobile devices currently. However, before even getting there I’ve already failed:
<html>
<head>
<script type="text/javascript" src="mdetect.js"></script>
</head>
<body>
<h1>header 1</h1>
<script type="text/javascript">
document.write(DetectIphoneOrIpod());
</script>
<p>this is normal body text</p>
</body>
</html>
What am I doing wrong? I haven’t even gotten to the complicated stuff (for me at least). Why won’t it write true or false depending on what’s returned from that function? Any help is appreciated.
Thanks
I think what you want to do is something like this:
However, you probably want to use the
DetectSmartphone()orDetectMobileQuick()functions to detect more mobile devices than just iPhones and iPod Touches.