我正在使用Web平台的一些功能,例如HTML Imports.
在Chrome 52上,一切正常,正如预期的那样.我知道IE11和FF 47上的HTML Imports存在问题.
但是我被要求在IE-11上为某些用户部署我的网络应用程序.这里开始痛苦.正如可以在互联网上找到的一些文章所建议的那样,我在我的index.html的头部调用了webcomponents polyfills,这是"导入器"文件:
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.3.3/platform.js"></script>
Run Code Online (Sandbox Code Playgroud)
也在头部本身:
<meta http-equiv="X-UA-Compatible" content="IE=Edge;FF=3;OtherUA=4" />
Run Code Online (Sandbox Code Playgroud)
用于实例化链接选择器的代码,其动态内容基于app状态:
var link = document.createElement('link');
link.rel = 'import';
link.href=ubicacion;
link.onload = function(e) {console.log('Loaded import: ' + e.target.href);};
link.onerror = function(e) {'Error loading import: ' + e.target.href};
document.head.appendChild(link);
Run Code Online (Sandbox Code Playgroud)
在IE-11上加载时,我在控制台中收到三条错误消息:
Loaded Import: https://www.example.com/import.html
SCRIPT5007: Can't get 'querySelector' property of null reference or undefined.
Can't set property 'innerHTML' of reference null or undefined.
Run Code Online (Sandbox Code Playgroud)
在index.html文件的末尾,我输入以下代码:
var div = document.getElementById('vista');
var view = document.querySelector('link[rel="import"]');
var content = view.import;
var el …
Run Code Online (Sandbox Code Playgroud)