View · Index

Body Onload javascript event

API calls for adding javascript

 

template::add_event_listener

add event listener for a single ID or for a CSS class. When using this call, the provided JavaScript snipped will be added suitable for content security policies (by adding nonces).

Example:

    template::add_event_listener \
        -id edit-tags-control \
        -script [subst {document.getElementById("edit_tags").style.display="block";}]

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.

template::add_event_listener

Add a script to the start of the body section of the document to be returned to the users client.

 

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>
previous December 2024
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 1 2 3 4

Popular tags

17 , 5.10 , 5.10.0 , 5.10.1 , 5.9.0 , 5.9.1 , ad_form , ADP , ajax , aolserver , asynchronous , bgdelivery , bootstrap , bugtracker , CentOS , COMET , compatibility , CSP , CSRF , cvs , debian , docker , docker-compose , emacs , engineering-standards , exec , fedora , FreeBSD , guidelines , host-node-map
No registered users in community xowiki
in last 30 minutes
Contributors

OpenACS.org