User:Тишина/guides/JavaScript hacks

I'm developing a list of hacks that can be used by administrators to change their wikis. JavaScript features can be added through the wiki interface by administrators without requesting changes to the PHP code on the server. Miraheze also gives any user the ability to customize their own view of the site with personal JavaScript and CSS pages.


 * Implementing code on your wiki

Ending a page title in .js will consider the page a code page and trigger the code editor when editing the script.

Scripts can be added by using the  method to call the URL of the script page and adding   to the end of the URL so only the source code of the page is loaded.

Example of a script import:

Ways to make sure users have JavaScript enabled
If you design your wiki functionality using JavaScript then you probably want your visitors to have it enabled in their browser. Administrators need to carefully consider that the more they nag users to enable JavaScript, the more likely it is that the user will abandon the wiki.

A simple way to create a nag would be to create an HTML ID around a message in the site notice that asks visitors to enable JavaScript and to delete the nag with JavaScript. It's up to administrators to decide how aggressive they want the nag to be. Keep in mind that visitors can remove this type of nag using browser extensions.

Add a message to the top of the page
The easiest way to add a message to the top of the page is to use the MediaWiki:Sitenotice page that will include wiki code at the top of the page. This will probably be your best option for simple text.

Replace page content
This code would be useful for creating a page with a form to take input from the user.