0

I installed a and my version is 1.21.1, now I want to add some code when the page is onload using . I have searched on the Internet and found we can put our scripts on the Common.js file, but I don't found Common.js in my wiki project. I have searched the whole directory and still did not find it.

Anyone could tell me how to achieve my goal?

Nemo
  • 2,441
  • 2
  • 29
  • 63
flyingfox
  • 13,414
  • 3
  • 24
  • 39
  • `MediaWiki:Common.js` is a *page* on your wiki (e.g. https://en.wikipedia.org/wiki/MediaWiki:Common.js), it's not a file on your webserver. – svick Mar 20 '14 at 12:43
  • @svick You mean Common.js is a page generate by the wiki?Then how can I add some script do it? My local address is 'http://localhost:8085/mediawiki',and I have tried all methods to view the page and always get 404 error,could you tell me the right URL address to view this file,please?Thank you very much@ – flyingfox Mar 21 '14 at 05:10
  • 1
    Enter MediaWiki:Common.js into the search box of your wiki. It will tell you the page doesn't exist - just create it. Any JS code you put in there will be executed on every page load. Of course, you have to be an administrator to create or edit that page. – brightbyte Mar 21 '14 at 12:56
  • @brightbyte Thank you very much and could you tell me where should I put the create Common.js file? – flyingfox Mar 22 '14 at 08:15
  • @brightbyte thank you very much,I have done as you wrote and it works now! – flyingfox Oct 31 '14 at 09:33
  • possible duplicate of [How to add custom global javascript to mediawiki](http://stackoverflow.com/questions/29902768/how-to-add-custom-global-javascript-to-mediawiki) – Ilmari Karonen May 02 '15 at 22:07

1 Answers1

1

brightbyte's answer, which worked: Enter MediaWiki:Common.js into the search box of your wiki. It will tell you the page doesn't exist - just create it. Any JS code you put in there will be executed on every page load. Of course, you have to be an administrator to create or edit that page.

This is documented at Manual:Interface/JavaScript; there are similar customisations at Manual:User group CSS and Javascript and Manual:Page customizations.

Nemo
  • 2,441
  • 2
  • 29
  • 63