Wikipedia:User scripts/Guide: Difference between revisions
Content deleted Content added
Line 325:
==== Adding elements ====
There is a special function in <code>mediawiki.util</code>, <code>[https://www.mediawiki.org/wiki/ResourceLoader/Core_modules#addPortletLink mw.util.addPortletLink()]</code> that simplifies the process of adding your own links to portlets. The advantage of using this function is that your code should work across all skins, and not break when these skins change their HTML. Its parameters, in order:
* <code>portletId</code> – ID of the target [[#Portlets (menus and tabs)|portlet]]
* <code>href</code> – link URL; set to <code>#</code> if you don't need to open a page and want to use a JavaScript listener instead
* <code>text</code> – human-readable link text
* <code>id</code> (optional) –
* <code>tooltip</code> (optional) – helpful text appearing on mouse hover
* <code>accesskey</code> (optional) – [https://www.w3schools.com/tags/att_global_accesskey.asp keyboard shortcut key]; set to <code>null</code> if you don't need it
|