包含外部HTML的JavaScript在Chrome中工作,但在Internet Explorer和Firefox中不起作用
我用来导入外部HTML的脚本,它有我基于引导的导航栏,下面是Javascript:包含外部HTML的JavaScript在Chrome中工作,但在Internet Explorer和Firefox中不起作用,javascript,html,include,html-imports,Javascript,Html,Include,Html Imports,我用来导入外部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 =
<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>
var link=document.querySelector('link[rel=“import”]”);
//在导入中克隆。
var template=link.import.querySelector('template');
var clone=document.importNode(template.content,true);
document.querySelector('#navBar').appendChild(克隆);
在我的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?互联网爆炸器?
没有 但是,您可以使用这样的多边形填充:
只有Chrome浏览器支持HTML导入。您应该为不同的浏览器使用不同的浏览器。只有Chrome浏览器支持HTML导入。您应该为不同的浏览器使用一个