So I have a Struts/Tiles page that I need to have a
Javascript function called on when the page loads.  Normally this is of
course accomplished with the BODY onLoad event however this event isn't
fired when my page loads and from doing extensive Googling I've found
that this has something to do with the nature of Struts/Tiles pages
(though I'm not sure what).  What is the best workaround for this?

You've gotten a number of answers that may have already helped you; none, however, are in the context of the challenge we met with tiles and onload handlers. In our tilesets, we usually have the "<body>" tags in a shared file, while the "meat" of the page which might require an onload hander is loaded from a different JSP. We didn't always have an onload handler, so we didn't know what to put in the shared tile page which included the body tags.


For a while, we used a solution like one posted here, where we just defined the onload handler as another tile attribute, and then could set it (or leave it blank) for each tiles definition as necessary.

Since then, though, I've realized that because Javascript functions are objects, you can actually assign the onload handler in javascript...


function myHandler { ... } document.onload = myHandler;

This seems tidier than having to use a tiles attribute.

Joe

--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining."
-- Jef Raskin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to