//part 1
addOnloadHook(func_start); //means «execute func_start later»
//part 2 — executed when the page is loaded
function func_start (){
//quite often it simply adds a javascript link
<a onclick="func_action()" href="#">
}
//and then there is …
//part 3 — executed when user clicks on this link
function func_action (){
}
<form name="frmname" id="frmid">
<textarea name="txtname" id="txtid">
<input id="neighbor">
if (document.URL.indexOf('action=history') != -1) {
//continue only on history pages
if (wgCanonicalNamespace == 'User_talk') {
//continue only on User_talk pages
function func_start () {
if (!document.editform) return; //no edit form → exit
… …
<div id="…" class="portlet">
<h5>Header</h5>
<div class="pBody">
<ul>
<li id="…"> <a …> //links
<li id="…"> <a …>
… …
//Example: add the link into «toolbox» portlet
addPortletLink ('p-tb', '/wiki/Special:MyPage/monobook.js', 'My monobook.js');
//Example: using innerHTML to create a new portlet
document.getElementById('p-participation').innerHTML +=
'</div>'+
'<div id=my class=portlet>'+
'<h5>mine</h5>'+
'<div class=pBody><ul>'+
'<li><a href=\"/wiki/Special:MyPage/monobook.js\">My monobook.js</a>'+
'</ul></div></div>';
//Example: remove copyright warning from edit page
var el = document.getElementById('editpage-copywarn');
if (el) el.style.display = 'none';
//Example: modify signature button.
if (mwEditButtons.length >= 10 && mwEditButtons[9].tagOpen == '---[[User:Goodshoped35110s|<font color="#006400">Go</font>]][[User talk:Goodshoped35110s|<font color="grey">od</font>]][[Special:Contributions/Goodshoped35110s|<font color="lightgreen">sh</font>]][[User:Goodshoped35110s/GI|op]][[User:Goodshoped35110s/G|ed]] 00:09, 24 November 2007 (UTC)')
mwEditButtons[9].tagOpen = ' — -[[User:Goodshoped35110s|<font color="#006400">Go</font>]][[User talk:Goodshoped35110s|<font color="grey">od</font>]][[Special:Contributions/Goodshoped35110s|<font color="lightgreen">sh</font>]][[User:Goodshoped35110s/GI|op]][[User:Goodshoped35110s/G|ed]] 00:09, 24 November 2007 (UTC)';
//Example: adding your own quick insert to Edittools
var specialchars = document.getElementById ('editpage-specialchars');
specialchars.innerHTML +=
"<a onclick=\"insertTags('<div>','</div>','');return false\"
href='#'><div></a>";