BTEC IT 单元 20 - 网站设计/JavaScript/弹出框
外观
弹出框(非结构化代码)
<input type="button" value="Click me" onclick="alert('Thanks... I feel much better now!');">
弹出框(结构化代码)
<head>
<script>
// Wait for DOM to load
document.addEventListener("DOMContentLoaded", function(event) {
// Put the button into a variable
var e = document.getElementById("go");
// Wait for user to click the button
e.addEventListener("click", function() {
// Do the alert box
alert("Hello");
}, false);
});
</script>
</head>
<body>
<form name="myForm">
<input id="go" type="button" value="Click me">
</form>
</body>