刚刚制作了一个基本程序来解决我的问题的根源,但我似乎找不到为什么它根本不起作用。
HTML
<html lang="en">
<head>
<script type="text/javascript" src="carjava.js"></script>
</head>
<body onload="hi()">
hi
</body>
</html>
JS
function hi() {
alert("hi");
}
我希望在页面加载时弹出警报,但没有任何反应,有什么想法吗?
最佳答案
我无法告诉你为什么它没有触发,但这应该有效:
HTML
<html lang="en">
<head>
<script type="text/javascript" src="carjava.js"></script>
</head>
<body>
hi
</body>
</html>
JS
function hi() {
alert("hi");
}
window.onload = hi;
关于javascript - 简单的 onload 事件没有触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15469804/