It can be detected if the device they access to my website is a cell phone or computer

0

I was wondering if with css or javascript I could detect if my user used a cell phone or PC is to alter the css since as there are events that do not work on cell I wanted the design to start differently than with the media queries can be detected the width but I mean detect if it's a cell phone or PC

    
asked by Israel David Villarroel Moreno 28.05.2018 в 22:04
source

2 answers

0

With CSS you can make use of Media Query and based on the dimensions of the screen make the necessary adjustments.

@media only screen and (max-width: 600px) {
    body {
        background-color: lightblue;
    }
}
    
answered by 28.05.2018 в 22:27
0

Yes, from javascript.

// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;

// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';

// Safari 3.0+ "[object HTMLElementConstructor]" 
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));

// Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;

// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;

// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
    
answered by 28.05.2018 в 22:56