File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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: 61092
    
  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: 61092
    
  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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: body onLoad