Because the desktop version of Safari doesn't support <input type="date">
, I want to tell the clients that use the desktop version of Safari that they should switch to another browser.
I've tried the following function, but it unfortunately returns Safari
even if I use Chrome.
function getBrowser() {
if((navigator.userAgent.indexOf("Opera") != -1 || navigator.userAgent.indexOf('OPR')) != -1 )
{
return 'Opera';
}
else if(navigator.userAgent.indexOf("Edge") != -1 )
{
return 'Edge';
}
else if(navigator.userAgent.indexOf("Samsung") != -1) {
return 'Samsung Browser';
}
else if(navigator.userAgent.indexOf("Safari") != -1)
{
return 'Safari';
}
else if (navigator.userAgent.indexOf("Chrome") != -1) {
return 'Chrome';
}
else if(navigator.userAgent.indexOf("Firefox") != -1 )
{
return 'Firefox';
}
else if(navigator.userAgent.indexOf("MSIE") != -1 )
{
return 'IE';
}
else
{
return 'unknown';
}
}
Is there another way how I can detect just if the client is using Safari? And if there is, is it possible to detect a user that's using the desktop version of it? Because on iPhone and iPad the <input type="date">
tags do work.