*
The moose likes HTML, CSS and JavaScript and the fly likes onload for JSP 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 "onload for JSP" Watch "onload for JSP" New topic
Author

onload for JSP

lijun wang
Greenhorn

Joined: Jan 20, 2006
Posts: 28
is there a onload()(javascript) method when I load JSP file?
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Do you mean this:

<BODY onload='alert("zut!")'>


There is no emoticon for what I am feeling!
lijun wang
Greenhorn

Joined: Jan 20, 2006
Posts: 28
I'm using JSF, so there is no body tag, but f:view instead
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Moved to the HTML/Javascript forum.


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

Joined: Jan 10, 2002
Posts: 60782
    
  65

Originally posted by lijun wang:
I'm using JSF, so there is no body tag, but f:view instead


If the f:view tag doesn't allow you to specify an onload handler (did you check?), you can do so in the header section of your page like so:

Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by lijun wang:
I'm using JSF, so there is no body tag, but f:view instead
Thanks


In fact, there is still a body tag. f:view doesn't replace or supercede it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Originally posted by Jeff Albertson:

In fact, there is still a body tag. f:view doesn't replace or supercede it.


In that case, I suspect the issue is that the OP is creating malformed HTML.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Also, if you have more than one user contributing to the page (i.e. the page composed from a different pieces that created by different people) you might want to add your onload functionality to the one that already exists.You can put this code anywhere inside body tag
 
 
subject: onload for JSP
 
Similar Threads
Replacing one DIV with another
How to access the request variable in the java script?
Capture the back page event in java script
To retrieve data from the database
how to know whether the browser is IE or netscape