DOM Method Write an html document with the following requirements: when the body of the document bas been loaded, an alert message “you are visiting this page” will be produced. Note that you only need to write the body part of the html document and the related JavaScript code. Hint:The intrinsic event attribute, onload, is associated with tho event that the body of a document has just been fully read and parsed by a browser.
时间: 2023-12-03 19:42:36 浏览: 293
Sure, here's an example of an HTML document that meets your requirements:
```html
<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
</head>
<body onload="showAlert()">
<h1>Welcome to my webpage!</h1>
<p>This is some sample text.</p>
<script>
function showAlert() {
alert("You are visiting this page.");
}
</script>
</body>
</html>
```
In this example, we've included a `onload` attribute on the `body` tag that calls the `showAlert()` function when the page has finished loading. The `showAlert()` function simply displays an alert message with the text "You are visiting this page." You can customize this message to say whatever you'd like.
阅读全文