我写了一个示例html页面来显示一个弹出div,它在firefox中工作,但不在IE中。它说这个函数是不确定的。Javascript函数在IE11中是undefined
这里是我的网页:
和错误消息是 “'show_popup_div未定义”
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=unicode" />
<script type="text/javascript">
function show_popup_div() {
var imageDiv=document.getElementById("image_div");
var switchA=document.getElementById("switch_a");
imageDiv.style.display='block';
}
async function hide_popup_div() {
var imageDiv=document.getElementById("image_div");
await sleep(5000);
imageDiv.style.display='none';
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
</script>
</head>
<body>
<a id="switch_a" onmousemove="show_popup_div()" onmouseout="hide_popup_div()">click me to open a image</a>
<div id="image_div">
<img id="image" src="http://www.rd.com/wp-content/uploads/sites/2/2016/02/06-train-cat-shake-hands.jpg" usemap="#map1"/>
</div>
</body>
我怎样才能解决这个问题?谢谢。
的可能的复制[如何做出承诺,在IE11工作(https://stackoverflow.com/questions/36016327/how-to-make-promises- work-in-ie11) –
IE11不支持'async' /'await'语法。它仅支持ECMAScript 5和一些ECMAScript 6功能。 – Dai