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 Software Craftsman this week in the Agile 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: 62307
    
  68

Please UseCodeTags.


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

Joined: Jan 10, 2002
Posts: 62307
    
  68

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.
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: body onLoad