Manual:Mediawiki.util

mediawiki.util is a MediaWiki Javascript library that provides access to various utility functions. It is one of the default ResourceLoader modules, and should be available from any page using the mw.util alias. Some of the functions in mediawiki.util are listed below.

wikiGetlink
Gets the relative URL for a particular page. For example: mw.util.wikiGetlink( 'Egypt–Saudi Arabia relations' ) will return "/wiki/Egypt%E2%80%93Saudi_Arabia_relations" on English Wikipedia.

wikiScript
Gets the URL to a particular server-side script. For example: mw.util.wikiScript( 'api' ) will return "/w/api.php" on English Wikipedia.

addCSS
Appends a new CSS style block to the head. Returns the styleSheet object (CSSStyleSheet) for convenience. mw.util.addCSS( '.foobar { display: none; }' )

getParamValue
Gets a particular parameter value from the current URL. For example if you are on the page http://en.wikipedia.org/w/index.php?title=Yellow&action=edit mw.util.getParamValue('action') will return "edit".