Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

MediaWiki Developer's Handbook/Add JavaScript/Predefined functions

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

This is wildly out-of-date, both these hooks are deprecated. Instead you use ResourceLoader to load JavaScript resources which typically use jQuery to run code at the appropriate event. (and yet some freewebhosts still only has old php, and we can only use old version of mediawiki) addOnloadHook() addOnloadHook(someFunction); This hooks onto the completion of the page load, and runs the specified function. You can run an anonymous function too: addOnloadHook(function(){ ... }); addHandler() addHandler(domElement,'action',someFunction); This hooks onto the action being performed on some DOM element, running the function. This can be useful for example if you want to change the user's input when submitting a form: function reallyChangeInput(){ ... } function changeInput() { form = document.getElementById('editform'); if (!form) return false; addHandler(form,'submit',reallyChangeInput); } addOnloadHook(changeInput);