Wikipedia:User scripts/Guide: Difference between revisions
Content deleted Content added
→Debugging: Adding more explanation and an example of another way to load a test css file. |
→Structure: Changed to show the new cleaner "addOnloadHook( function() {" approach we use nowadays. |
||
Line 17:
== Structure ==
When your <tt>/monobook.js</tt> is executed most [[HTML]] page elements do not exist yet. So most user scripts look like this:
<source lang="javascript">
//
addOnloadHook(
} );
▲//part 2 — executed when the page is loaded
▲ //quite often it simply adds a javascript link
▲ <a onclick="func_action()" href="#">
▲//and then there is …
//
function func_action (){
}
|