Angular 浏览网站时,IE文档模式设置为7
每当我通过IE浏览我的angular 6站点时,文档模式设置为IE7。 我的兼容模式设置为: 以兼容模式显示intranet站点-选中 使用Microsoft兼容性列表-未选中。 已添加到兼容性视图的网站中没有网站 My polyfills.ts配置为>=IE10。 这是我的poyfills.ts:Angular 浏览网站时,IE文档模式设置为7,angular,internet-explorer,compatibility,polyfills,ie8-compatibility-mode,Angular,Internet Explorer,Compatibility,Polyfills,Ie8 Compatibility Mode,每当我通过IE浏览我的angular 6站点时,文档模式设置为IE7。 我的兼容模式设置为: 以兼容模式显示intranet站点-选中 使用Microsoft兼容性列表-未选中。 已添加到兼容性视图的网站中没有网站 My polyfills.ts配置为>=IE10。 这是我的poyfills.ts: /** * This file includes polyfills needed by Angular and is loaded before the app. * You can
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
import 'classlist.js'
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
import 'core-js/es7/array';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
import 'core-js/es6/reflect';
/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import 'core-js/es7/reflect';
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
**/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
*/
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
/*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*/
// (window as any).__Zone_enable_cross_context_check = true;
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
尝试在站点中添加以下行可能有助于解决IE浏览器的问题
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
如果可能的话,您也可以尝试将HTTP响应头设置为X-UA-Compatible值:IE=edge(在服务器端)
如果问题仍然存在,请尝试提供有关该问题的更多信息。这里我假设您正在使用IE11 您没有提到您正在使用哪个IE版本或如何查看您的Angular站点,例如,它是否位于您的本地计算机或内部网上?这会影响用于呈现页面的区域,因此可能会影响用于呈现工作的文档模式。(我假设您使用的是IE11。如果您使用的是早期版本,则可能需要调整以下步骤。) 要验证用于为页面提供服务的区域,请右键单击页面的静态部分,选择“属性”,然后检查“区域:设置”的值(大约位于属性表的中间位置) 如果该区域是Intranet(意味着该站点由本地硬盘或网络提供服务),则可能是您的问题的原因。默认情况下,IE显示内部网页面 如果区域是Internet,则您会遇到另一个问题。可能您没有使用HTML5 doctype(
),或者其他配置设置正在强制您的站点进入传统文档模式
如果站点被迫进入传统文档模式,那么最好使用IE的开发人员工具查看当前文档模式。要执行此操作,请按[F12],选择仿真选项卡,然后检查文档模式下拉列表的值。如果这不是11,那么肯定有东西在干扰
确切地说,很难说,因为有很多方法可以控制事情。Deepak的答案中的这一行可能会有所帮助,但前提是它位于除此之外的所有内容之上
如果您发现自己处于这种情况,请检查有关IE文档模式的SO线程。可能包括:服务器站点标题(例如.htaccess
)、组策略更新、注册表设置更改等
或者,由于IE正式不再更新,你可以,你知道,让它去吧。假设您正在设计您的站点,使其也能用于屏幕阅读器和其他不常见的浏览条件,您可以简单地将IE支持放在同一个容器中