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
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: 374
<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: 60775
    
  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: 60775
    
  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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: body onLoad
 
Similar Threads
iFrame src doesn't update
How to determine if one frame has loaded from another?
Problrm in calling userdefined method in onclick event of button dynamically
Javascript document object writes in a new page?
Problem compiling the code