Talk:How to enhance wiki content with JavaScript
Add topicThis howto is easy to understand also without js skill. but I had to change the js code (from MediaWiki:YourScript.js) as it is described here http://jsfiddle.net/7f9uko44/ (thanks to Krinkle from "mediawiki-l Mail-List"). I did the import code as recommended with importScript('MediaWiki:YourScript.js') (in MediaWiki:Common.js); and create a Template:HelloWorld and use that within pages but nothing happens. Do I forgot to activate or to allow js in mediawiki settings? In LocalSettings.php I set: $wgUseSiteJs = true; $wgAllowUserJs = true; $wgAllowUserCss = true; Is there any simple way to check js is running in my mediawiki? Ggtuem (talk) 14:16, 4 September 2014 (UTC)
why not support js newbies with a "hello world" howto? Ggtuem (talk) 10:57, 5 September 2014 (UTC)
Example Hello World!!!
[edit]Here is a quick step-by-step for Hello World!!!:
Add to the following MediaWiki:Common.js:
(function () { var myElement = document.getElementById('mw-hello-world'); myElement.innerHTML = '<html>Hello World!!!</html>'; }());
Create the page Template:Helloworld with the following:
<div id="mw-hello-world"></div>
Go to a regular page in the wiki and add the following:
{{Helloworld}}
You should see Hello World!!! on the page after saving. Nephron (talk) 02:05, 28 October 2016 (UTC)
importScript is now deprecated
[edit]importScript is now depricated
Please replace the code snippet under Separate Script
importScript('MediaWiki:Example.js');
with the updated version
mw.loader.load( '/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );
See https://www.mediawiki.org/wiki/ResourceLoader/Legacy_JavaScript#importScript
Thanks.
I don't understand. We can't embed static Javascript to a Wiki page? How is that a security threat?
[edit]Getting passwords works with .php etc. doesn't it? — Preceding unsigned comment added by 188.155.21.181 (talk • contribs) Ciencia Al Poder (talk) 11:21, 12 May 2021 (UTC)
- There are more threats than stealing passwords. Redirect users to sneaky websites that can exploit browser vulnerabilities or phishing (where they can steal passwords), rewrite the page to make it look like the login page but actually send your credentials to some other site, do criptomining, etc. --Ciencia Al Poder (talk) 11:21, 12 May 2021 (UTC)