[英]JavaScript to include external HTML is working in Chrome but not in Internet Explorer and Firefox
The script that I am using to import external HTML which has my Bootstrap based Navbar, here is the Javascript: 我用来导入具有基于Bootstrap Navbar的外部HTML的脚本,这是Javascript:
<script type="text/javascript">
var link = document.querySelector('link[rel="import"]');
// Clone the <template> in the import.
var template = link.import.querySelector('template');
var clone = document.importNode(template.content, true);
document.querySelector('#navBar').appendChild(clone);
</script>
In my HTML page, all I am doing is including a reference to external html file in section and adding a div in my section with defined class name as follows: 在我的HTML页面中,我要做的就是在本节中包括对外部html文件的引用,并在本节中添加具有已定义类名的div,如下所示:
<!— link of external HTML file in <HEAD> section -->
<link rel="import" href="navbar.html">
<!— Div with defined class name “navBar”in <BODY> section -->
<div id="navBar"></div>
HTML5? HTML5? Internet Exploder?
Internet Exploder?
https://caniuse.com/#feat=imports https://caniuse.com/#feat=imports
Nope. 不。
Can use a polyfill like this though: 可以使用这样的polyfill:
https://github.com/webcomponents/html-imports https://github.com/webcomponents/html-imports
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.