我在防火墙内的Windows Server 2012 R2主机上已将Angularjs站点部署到IIS。当我RDP进入服务器并从那里导航到
http://localhost/Foo
在IE11中,一切都按预期运行;我的页面被提供给浏览器。
但是,当我尝试浏览时
http://servername/Foo
在IE11中,我从angular.js的第1016行抛出了一个错误
"Object doesn't support property or method 'querySelector'"
这仅在Internet Explorer中发生。
在Chrome和Firefox中,一切都进行了很好的测试。
是否有人知道为什么会发生这种情况以及我可以采取哪些措施来解决?
最佳答案
解决此问题的方法是添加
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
标签作为Head
中的第一项。meta标签必须是IE中首个使用边缘模式的标签;否则,它将忽略应该指示IE不要进入怪癖模式的DOCTYPE。
在部署时,我将meta标签作为事后思考,并在头部底部键入了它。
MSDN|Specifying Legacy Document Modes
The X-UA-Compatible header isn't case sensitive; however, it must appear in the header of the webpage (the HEAD section) before all other elements except for the title element and other meta elements.
Internet Explorer中的默认兼容性设置会导致IE静默地对内部站点和外部站点进行不同的行为。
设置X-UA-Compatible元标记可明确声明浏览器应在Edge模式下接收内部站点,而无需管理兼容性设置,但必须将 header 指定为 header 中的第一个标签,以实现此效果。
关于angularjs - 当在IE11中通过计算机名称访问站点时,显示“Object doesn'支持属性或方法'querySelector',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25632927/