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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 370
<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: 60048
    
  65

Please UseCodeTags.


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

Joined: Jan 10, 2002
Posts: 60048
    
  65

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: body onLoad
 
Similar Threads
Problem compiling the code
iFrame src doesn't update
Problrm in calling userdefined method in onclick event of button dynamically
Javascript document object writes in a new page?
How to determine if one frame has loaded from another?