无法在IE或Microsoft Edge中正常运行视差。我在论坛上找过了,还没有找到解决这个问题的办法。我希望现在能想出一个解决方案。如果用户使用IE或Edge,我想显示一条消息。我不确定如何才能检测到正在使用的浏览器是one还是one。
下面是我正在尝试使用的一些javascript代码:
<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');
}任何帮助都将不胜感激,或者如果有更好的解决方案。
http://peaceandplentyinn.mybnbwebsite.com
发布于 2015-10-15 23:40:50
我怀疑你真的需要检测浏览器。但不管怎样,这就是它(实际上并不需要使用库):
// detect IE8 and above, and edge
if (document.documentMode || /Edge/.test(navigator.userAgent)) {
alert('Hello Microsoft User!');
}发布于 2017-05-28 05:43:47
对我来说更好的是:
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;去跑步:http://jsfiddle.net/Webnewbie/apa1nvu8/
发布于 2020-06-04 20:34:53
我使用这些函数,即使将用户代理设置为其他值,它们也可以工作。
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!');
}这会检测到Chredge/Edgium (也就是阿纳海姆)
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;
}这是检测铬的方法:
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;
}https://stackoverflow.com/questions/33152523
复制相似问题