我在HTML5中制作了一个模板,可以在Chrome和Firefox上使用,但无法在Internet Explorer(在IE 8上测试)上使用。
我该如何解决这个问题?
我在HTML5中制作了一个模板,可以在Chrome和Firefox上使用,但无法在Internet Explorer(在IE 8上测试)上使用。
我该如何解决这个问题?
<template id="fancyTemplate" style="display:none"></template>
<template>
内容,无论它是否在<head>
中。 - dakab获取html4shiv的副本,并在IE版本小于9的情况下使用它:
<!--[if lt IE 9]>
<link rel="stylesheet" href="styles/ie.css" type="text/css"> <script src="scripts/ie/html5shiv.min.js"></script>
<![endif]-->
<template>
标签在IE的所有版本中都无法使用,不仅仅是旧版本。不确定html5shiv是否可以解决这个问题... - Alvaro<script>
标签替换<template>
标签。<script id="fancyTemplate"></script>
<script type="text/x-template" id="fancyTemplate"></script>
- BYTE RIDERtemplate { display:none !important; }
如果需要像其他浏览器一样本地访问/克隆内容,请使用此polyfill:https://github.com/jeffcarp/template-polyfill
但请记住,<template>
的内容仍然可以在DOM中找到并执行-防止这种情况发生是该标签的主要目标。没有polyfill可以阻止IE再次减缓现代Web开发的速度。