4
  1. I fresh installed MediaWiki on my own server (latest version)

  2. I tried adding some JavaScript code to MediaWiki:Common.js

  3. In localsettings.php, $wgAllowUserJs is set to true

  4. I also tried adding the JavaScript to User:Admin/vector.js and User:Admin/common.js

  5. I cleared cache/cookies, used different browsers, JavaScript enabled, tried different computers

The JavaScript code does not work at all. I viewed source and it's not there.

<!-- BEGIN Tynt Script -->
<script type="text/javascript">
    if(document.location.protocol=='http:'){
        var Tynt=Tynt||[];Tynt.push('cAe5WESDOr4BZUacwqm_6r');Tynt.i={"ap":"Read more:"};
        (function(){var s=document.createElement('script');s.async="async";s.type="text/javascript";s.src='http://tcr.tynt.com/ti.js';var h=document.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);})();
    }
</script>
<!-- END Tynt Script -->
3
  • 3
    Do not include <script> and </script> on the *.js page - it will be included as a separate JS file, not inline in the HTML page. Also, you don't need $wgAllowUserJs for MediaWiki pages (there is a separate setting for that, but it is on by default). Commented Jun 9, 2012 at 15:47
  • 2
    Note that $wgAllowUserJs enables User:<Username>/common.js while MediaWiki:Commons.js is controlled by $wgUserSiteJs Commented Jun 20, 2012 at 13:22
  • @Tgr Could you please add your comment as an answer below so we can get this off the unanswered list? Commented Sep 30, 2013 at 12:39

1 Answer 1

6

Do not include <script> and </script> on the *.js page - it will be included as a separate JS file, not inline in the HTML page.

Note that you don't need $wgAllowUserJs for javascript pages in the MediaWiki namespace, only for ones in the User namespace. (There is a separate setting called $wgUseSiteJs for enabling scripts in the MediaWiki namespace, but it is on by default).

Sign up to request clarification or add additional context in comments.

2 Comments

it's $wgUseSiteJs, not User... the link in this answer points at the right page, though.
Thanks, fixed. (Did you know you can just edit the answer?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.