aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes body onLoad Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "body onLoad" Watch "body onLoad" New topic
Author

body onLoad

ben oliver
Ranch Hand

Joined: Mar 28, 2006
Posts: 375
<html>
<head>
<script>
function createPage() {
document.write("I am creating a page\n");


}
</script>
</head>
<body onLoad="createPage()">

Hello World !


</body>
</html>


***************

Question --- I only see "("I am creating a page" when load this page. Why "Hello World!" is not printed ? I thought it is part of <body>, right ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

Please UseCodeTags.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61232
    
  66

document.write() replaces the current page when executed after load.

It's a dinosaur -- don't ever use it. There is no modern use for document.write(). There are better ways to do anything that document.write() used to be used for.
 
jQuery in Action, 2nd edition
 
subject: body onLoad