Hello good people.
I am trying to add a snippet of javascript to the head tag of a mobile site that checks if the visitor is using a PC and if the visitor is viewing the mobile site on a PC I want them to be redirected to the normal site.
The following code snippet is the best I could come up with. I am not too well versed in javascript but I thought I was close.
This code SHOULD check the user's screen width and if it is greater than a certain value then it will promt to the user to go to the normal website.
<!-- User Redirect Start - Detects the user's screen size and determines if they need to be redirected to the normal site. -->
<script type="text/javascript">
<!--
//Screen Size Check
var myFunc = function() {
if (screen.width > 799) {
confirm('Your screen resolution is wider than 799 pixels. This makes me think you are viewing this mobile site on a PC. If you are, click OK to be taken to the normal Desktop version of our site. If, I am mistaken then click CANCEL. Thanks.');{
document.location = "http://www.whitinfo.com";
}}}
//else alert('Well, okay, but I still think you are on a mobile device... Enjoy the site.') }
//-->
</script>
<!-- User Redirect End -->
Now, really what I was is for all of this to happen automatically without having to prompt the user but if I have to involve the user then it's okay.
Also, is there a better way to detect the user's platform?