- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我看了很多地方,我知道有很多方法可以检测 Internet Explorer。
我的问题是:我的 HTML 文档中有一个区域,单击该区域时会调用与任何类型的 Internet Explorer 都不兼容的 JavaScript 函数。我想检测是否正在使用 IE,如果是,则将变量设置为 true。
问题是,我是用 Notepad++ 编写代码的,当我在浏览器中运行 HTML 代码时,检测 IE 的所有方法都不起作用。我认为问题是我正在用 Notepad++ 运行它。我需要能够检测 IE,以便基于变量,我可以禁用站点的那个区域。我试过这个:
var isIE10 = false;
if (navigator.userAgent.indexOf("MSIE 10") > -1) {
// this is internet explorer 10
isIE10 = true;
window.alert(isIE10);
}
var isIE = (navigator.userAgent.indexOf("MSIE") != -1);
if(isIE){
if(!isIE10){
window.location = 'pages/core/ie.htm';
}
}
但它不起作用。如何从 Notepad++ 中检测到 IE?这就是我用来测试 HTML 的内容,但我需要一种适用于它的方法。
我注意到有人将其标记为重复,这是可以理解的。我想我不清楚。我不能使用 JQuery 答案,所以这不是重复的,因为我要求的是普通 JS 答案。
是否还有检测 Microsoft Edge 浏览器的方法?
最佳答案
这是我所知道的最新正确的IE和Edge检查方法:
if (/MSIE 10/i.test(navigator.userAgent)) {
// This is internet explorer 10
window.alert('isIE10');
}
if (/MSIE 9/i.test(navigator.userAgent) || /rv:11.0/i.test(navigator.userAgent)) {
// This is internet explorer 9 or 11
window.location = 'pages/core/ie.htm';
}
if (/Edge\/\d./i.test(navigator.userAgent)){
// This is Microsoft Edge
window.alert('Microsoft Edge');
}
请注意,您的代码中不需要额外的 var isIE10,因为它现在会执行非常具体的检查。
另请查看此页面以获取最新的 IE 和 Edge 用户代理字符串,因为此答案有时可能会过时:https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx
关于javascript - 如何使用 JavaScript 检测 Internet Explorer (IE) 和 Microsoft Edge?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31757852/
我想通过注册表更改 Edge 浏览器中的主页,但它是加密的,我在注册表中看到( protected - 修改违反 Windows 策略。请参阅 aka.ms/browserpolicy)。请帮助我在注
如果我开发一个网站,它是否会以相同的方式在 IE11、Chrome、Firefox 和 edge 上运行,还是我们需要专门为 IE11 编写代码?我没有 Windows 8,因此无法在边缘浏览器上测试
如果我开发一个网站,它是否会以相同的方式在 IE11、Chrome、Firefox 和 edge 上运行,还是我们需要专门为 IE11 编写代码?我没有 Windows 8,因此无法在边缘浏览器上测试
如果 Edge 在某些机器上发生崩溃,我们需要检查日志以了解发生了什么情况。 最佳答案 Microsoft Edge 实际上是一个 Windows 进程,因此您应该能够在事件查看器中查看日志。此外,您
我们公司已将 Chrome 扩展程序移植到 Edge。扩展工作正常,但弹出窗口本身有很多重要内容。如果您在扩展设置中切换“地址栏旁边的显示按钮”,边缘扩展似乎只显示弹出按钮。这通常是一种糟糕的用户体验
我正在尝试在 Microsoft Edge 中调试崩溃的应用程序,但它提供了友好的错误页面: This page is having a problem loading We tried to loa
经过长时间的研究,我创建了我的最佳电子书 (Epub) 阅读器。作为主要设备,我基本上使用 Windows 10 平板电脑和 Microsoft Edge 作为 (Epub) 阅读器。 这是伟大的和惊
如何使用注册表或命令行获取 Microsoft Edge 浏览器版本? 我不想从 UI 中获取它。 最佳答案 对于 Microsoft Edge Legacy ,您可以使用 Get-AppxPacka
是否有可靠的编程方式来确定 Microsoft Edge 是默认浏览器? 我知道一种选择是使用 IApplicationAssociationRegistration::QueryCurrentDef
当人们在 Edge 中浏览网站时,很高兴看到“阅读 View ”按钮已启用。想要了解一个页面如何适合阅读模式。这将有助于开发人员在开发网站时牢记阅读模式。 最佳答案 答案来自 Microsoft Ed
我们在三周前向申请表提交了 Microsoft Edge 扩展:https://aka.ms/extension-request . 我们还没有收到任何反馈,在开发者仪表板中提交扩展包时,我们收到以下
我可以运行 code 从 WSL2 内部启动 VSCode。 我将如何启动 Edge(当前基于 Chromium 的 Edge)? 我试过了: ~/Code/company/workshops-web
最新版本的 Microsoft Edge 浏览器 (41.162...) 在单击后退和前进按钮时请求新页面。我在多个平台上测试了多个浏览器,只有 Edge 表现出这种行为。 这是一个 test pag
我在 Windows 1803 版本 17134.376 中使用 Microsoft Edge。 我有一个在 IIS 中本地运行的 ASP.NET Core 网站。该网站在 Edge 中可以正常打开,
Edge on Desktop 未加载谷歌字体。事实上,它甚至没有使用被定义为回退的“sans-serif”。 此行为不会在 Mobile Edge 中复制。 How it should look l
iotedge logs 暴露的日志在哪里?命令存储? 通常在 Linux 上会在哪里? 最佳答案 只需执行 docker inspect 及以下 LogPath您将获得容器的当前位置。例如。对于
我正在尝试将 Polymer 2 组件集成到现有的 SPA([ab] 使用 JSF 构建)。只要我的 POC 在 Chrome 中运行,我的基础知识就可以正常工作,我真的不在乎它是在 Shadow 还
我们的大型单页 JavaScript 应用程序在 Edge 浏览器中根本无法运行。 (我们在 Chrome 和 Firefox 中正式支持它,我们不允许在 IE 中使用它,因为它只能在那里工作一半,我
Microsoft Edge 16 中存在错误(已多次报告并在此处确认:https://developer.microsoft.com/en-us/microsoft-edge/platform/is
Microsoft Edge 16 中存在错误(已多次报告并在此处确认:https://developer.microsoft.com/en-us/microsoft-edge/platform/is
我是一名优秀的程序员,十分优秀!