How to judge whether it is a personal computer or a smartphone with js
I would like to judge whether the terminal accessing by making js is a personal computer or a smartphone. There is no such thing as saying.
html
<p id="text">Wich one</p>
js
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
var p = document.getElementById('text');
p.innerHTML = 'Mobile'
}else{
var p = document.getElementById('text');
p.innerHTML = 'pc'
}