我在 Internet Explorer 8 上写了一些非常简单的代码,但我不明白为什么当我用 IE 打开页面时没有任何反应(为什么页面上没有出现文本“test”)。
我已经在 Firefox 和 Chrome 上试过了,它们运行得很好。
我的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso 8859-1" />
<script type="text/javascript">
function display() {
output.innerHTML+='test';
}
</script>
</head>
<body onload="display()">
<div id="output">
</div>
</body>
</html>
编辑:让 IE 更改您的设置,不要手动进行,否则会变得很奇怪:-))
最佳答案
document.getElementById('output').innerHTML += 'test';
关于javascript - Onload 事件不适用于 Internet Explorer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5965160/