【发布时间】:2018-01-14 05:53:07
【问题描述】:
我写了一个示例 html 页面来显示一个弹出 div,它在 Firefox 中工作,但在 IE 中不工作。它说函数未定义。
这是我的页面:
并且错误消息是“'show_popup_div' is undefined”
<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 不支持
async/await语法。它仅支持 ECMAScript 5 和一些 ECMAScript 6 功能。
标签: javascript html