MDL-10249 Created addonload JavaScript function that can be used to add onload handlers, instead of using <body onload> which breaks things.

This commit is contained in:
sam_marshall
2007-06-25 14:38:02 +00:00
parent 50ebd1258e
commit 7470d6de7a
2 changed files with 17 additions and 2 deletions
+3 -2
View File
@@ -78,11 +78,12 @@ function inserttext(text) {
if(($pos = strpos($focus, '.')) !== false) {
//old style focus using form name - no allowed inXHTML Strict
$topelement = substr($focus, 0, $pos);
echo "function setfocus() { if(document.$topelement) document.$focus.focus(); }\n";
echo "addonload(function() { if(document.$topelement) document.$focus.focus(); });\n";
} else {
//focus element with given id
echo "function setfocus() { if(el = document.getElementById('$focus')) el.focus(); }\n";
echo "addonload(function() { if(el = document.getElementById('$focus')) el.focus(); });\n";
}
$focus=false; // Prevent themes from adding it to body tag which breaks addonload(), MDL-10249
} ?>
//]]>