I've noticed that head.js
doesn't detect Microsoft "Edge" browser, and to top that, it adds incorrect chrome
and chrome55
classes to the <html>
element.
Does anyone know of a suitable way to approach this issue? The best approach I could come up with is to perform this check in my app's bootstrap - manually detect "Edge" browser, add appropriate "ms-edge" class, and remove head.js incorrect "chrome" classes:
if (window.navigator.userAgent.indexOf('Edge') > -1) {
$('html').removeClass(function(index, classes) {
return classes.match(/\bchrome.*?\b/g).join(' ');
}).addClass('ms-edge');
}
asked Jan 17, 2017 at 9:15
ShayaShaya2,95233 gold badges3030 silver badges3838 bronze badges
you should be using some thin like this
var str= window.navigator.userAgent.toString().toLowerCase();
// This will return "mozilla/5.0 (windows nt 6.1) applewebkit/537.36 (khtml, like gecko) chrome/55.0.2883.87 safari/537.36"
In the above string you need to check your conditions as below
if (str.includes("edge") == true) {
$('html').removeClass(function(index, classes) {
return classes.match(/\bchrome.*?\b/g).join(' ');
}).addClass('ms-edge');
}
Screen shots of various test in the browser console.
answered Jan 17, 2017 at 9:26
AravindAravind41.7k1616 gold badges9797 silver badges111111 bronze badges
5Start asking to get answers
Find the answer to your question by asking.
Ask questionExplore related questions
See similar questions with these tags.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4