There are many occasions when one needs to add some javascript that requires something like
<body onLoad="dosomething">
(even some of the TWiki templates have an
onLoad="initForm()"
in the body tag.
I suggest to add a function akin to
TWiki::addToHEAD
that let's one collect up material to stuff into the
onLoad
attribute of the body tag.
I've got the code written, but before I update all the templates, I'd prefer some feedback.
--
TW
How about using a preferences variable instead? This gives TWiki applications the opportunity to manipulate the body tag. Such as a BODYTAGATTR setting in TWikiPreferences, initialized to an empty value. All skins would have somehing like
<body class="patternViewPage" %BODYTAGATTR%>
--
PTh
Be careful with
body onload
handlers. Because many parts of a TWiki page want to have control over the onload (multiple plugins, the skin), we now use this method:
<script type="text/javascript">
//<![CDATA[
addLoadEvent(myFunc);
function myFunc () {
// initializing code
}
//]]>
</script>
AC
AC, great advice. Works neat and does not require any new feature for TWiki. Thanks. --
TW
Documented in
TWiki:TWiki.SkinsAndJavaScript
. --
AC