Forum OpenACS Development: Adding onload to body tag.

Collapse
Posted by Alex Kroman on
Hello,

I need to add a piece of javascript bo be called from body onload in one of my templates. I added the code to make this work in blank-master.tcl but I can't figure out how to insert the javascript from within my page (I obviously don't want to edit a master file)

Alex

Collapse
Posted by Andrew Piskorski on
You simply need to pass your content (be it Javascript or anything else) through some approate variable @foo@ in the templated pages until it ends up wherever you want it.

In they case of your Javascript, I'm not sure just where it should end up. I see in www/blank-master.tcl (on OpenACS 5.1.5.x) some code doing stuff like this:

set onload {} 
lappend onload "acs_initHtmlArea(editor_var_${htmlarea_id}, '${htmlarea_id}');" 
which makes me suspect that those templates are not set up to let you pass in your own OnLoad stuff, you'd need to hack it to let you do so.

Why don't you want to edit one of your master templates? It's not at all obvious to me why you don't want to.