Borja
Borja

Reputation: 3559

How detect Safari browser ONLY on desktop?

How detect Safari browser ONLY on desktop ?
I want to know only when user is on desktop and not with mobile device.

var ua = navigator.userAgent.toLowerCase(); 
if (ua.indexOf('safari') != -1) { 
    //find safari
}

I noticed that Desktop Safari doesn't support input[type=date] but mobile safari (the name is webkit ?) yes. So for me is important understand when user is on desktop.

Thanks a lot and sorry for my english.

Upvotes: 3

Views: 6969

Answers (1)

Stefan Blamberg
Stefan Blamberg

Reputation: 844

const uA = navigator.userAgent;
const vendor = navigator.vendor;
if (/Safari/i.test(uA) && /Apple Computer/.test(vendor) && !/Mobi|Android/i.test(uA)) {
  //Desktop Safari
}

Upvotes: 10

Related Questions