Home
The Toolkit for Online Communities
15265 Community Members, 1 member online, 2254 visitors today
Log In Register

Body Onload javascript event

OpenACS Home : xowiki : Body Onload javascript event
Search · Index
Previous Month May 2012
Sun Mon Tue Wed Thu Fri Sat
29 30 1 (1) 2 3 4 (1) 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 (1) 24 25 26
27 28 29 30 31 1 2

Popular tags

ad_form , ADP , ajax , aolserver , asynchronous , bgdelivery , bugtracker , COMET , cvs , debian , emacs , FreeBSD , includelets , install , installation , installers , javascript , libthread , linux , monitoring , nginx , oracle , osx , patches , performance , postgres , pound , redhat , selenium , ssl

No registered users in community xowiki
in last 30 minutes

Contributors

OpenACS.org

No registered users in community xowiki
in last 10 minutes

Body Onload javascript event

The latest technique makes a consistent API for adding code into the document:

The new template::head and template::add_body_handler

Adds javascript code to an event handler in the body tag. Several javascript code blocks may be assigned to each handler by subsequent calls to template::add_body_handler.

If your script may only be added once you may supply an identifier. Subsequent calls to template::add_body_handler with the same identifier will replace your script rather than appending to it.

event may be one of:

@param event the event during which the supplied script should be executed

@param script the javascript code to execute

@param identifier a name, if supplied, used to ensure this javascript code is only added to the handler once

DEPRECATED:

There was no easy way to add onload event to openacs, unless you edit www/site-master.tcl, but now you can define within you own package what functions you want to be for onload javascript event. This tcl callback definition will work for any page.

ad_proc -public -callback subsite::header_onload -impl my_onload {} {
    return the function to load when the page is served
} {

    return {my_javascript_function();}

}

Or in case you want it for a single page, or for you custom template, use the template property to send it:

  <property name="body(onload)">
   my_javascript_function();
  </property>

Alternatively, as the on_load property tag has been deprecated, you could in your .tcl file set a variable

set my_function_name "my_javascript_function();"

then in the .adp

<property name="body(onload)">
     @my_function_name;noquote@
  </property>