Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

How to distinguish a Windows laptop from a tablet in Javascript?

$
0
0

Hi all! :)

I need a way to detect in Javascript, when the user is running Internet Explorer 10 or newer, whether they're browsing my website using a Windowslaptop vs a tablet.

I wrote this Javascript function to detect a Windows tablet:

function is_win_tablet()
{
	return (navigator.userAgent.toLowerCase().indexOf("windows nt") != -1 &&
		navigator.userAgent.toLowerCase().indexOf("touch") != -1);
}

However, it's wrong. When I'm using my laptop with touch screen, this function detects it as a tablet.

How do I distinguish if the user is viewing my website with IE on a laptop vs a tablet? Thank you in advance for your help! :)


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>