window.onload = () => { if(navigator.userAgent.match(/(iPhone|iPad|iPod|iOS)/i) || navigator.userAgent.match(/Android/i)){ console.log('mobile!'); } else { console.log('PC!'); } }