Reputation: 345
Can't get Parallax working properly in IE or Microsoft Edge. I've looked in forums and haven't found a solution to the problem. I've come up with hopefully a solution for now. I want to make a message appear if the user is using IE or Edge. Not sure how I can detect that the browser being used is one or the either.
Here is some javascript code I'm trying to work with:
<script src="https://github.com/ded/bowser/blob/master/src/bowser.js"></script>
// Determine Browser Used
browser = require('bowser').browser; becomes browser = require('bowser');
if (bowser.msie || bowser.msedge) {
alert('Hello Microsoft User');
}
Any help would be appreciated or if there is a better solution.
http://peaceandplentyinn.mybnbwebsite.com
Upvotes: 27
Views: 48807
Reputation: 82306
I use these functions, which work even if the user agent is set to something else.
if (document.documentMode)
{
console.log('Hello Microsoft IE User!');
}
if (!document.documentMode && window.msWriteProfilerMark) {
console.log('Hello Microsoft Edge User!');
}
if (window.msWriteProfilerMark)
{
console.log('Hello Microsoft User!');
}
And this detects Chredge/Edgium (aka. Anaheim)
function isEdg()
{
for (var i = 0, u="Microsoft", l =u.length; i < navigator.plugins.length; i++)
{
if (navigator.plugins[i].name != null && navigator.plugins[i].name.substr(0, l) === u)
return true;
}
return false;
}
And this detects Chromium:
function isChromium()
{
for (var i = 0, u="Chromium", l =u.length; i < navigator.plugins.length; i++)
{
if (navigator.plugins[i].name != null && navigator.plugins[i].name.substr(0, l) === u)
return true;
}
return false;
}
Upvotes: 1
Reputation: 151
For me better this:
var uA = window.navigator.userAgent,
isIE = /msie\s|trident\/|edge\//i.test(uA) && !!(document.uniqueID || document.documentMode || window.ActiveXObject || window.MSInputMethodContext),
checkVersion = (isIE && +(/(edge\/|rv:|msie\s)([\d.]+)/i.exec(uA)[2])) || NaN;
Go run: http://jsfiddle.net/Webnewbie/apa1nvu8/
Upvotes: 2
Reputation: 1379
I doubt you really need to detect the browser. But here it is anyway (don't really need to use a library):
// detect IE8 and above, and edge
if (document.documentMode || /Edge/.test(navigator.userAgent)) {
alert('Hello Microsoft User!');
}
Upvotes: 76