0

I placed this code .scriptonly { display: none; } in Mediawiki:Noscript.css and then used <div class="scriptonly">Content </div> on my page and the content displays only for javascript enabled users.

How do i do same for users who have javascript disabled?

rapito
  • 11
  • 1
  • Possible duplicate of [How to detect if JavaScript is disabled?](https://stackoverflow.com/questions/121203/how-to-detect-if-javascript-is-disabled) – Alon Eitan Aug 23 '19 at 15:06

3 Answers3

0

You can use <noscript> tag

https://www.w3schools.com/tags/tag_noscript.asp

David Rojo
  • 2,337
  • 1
  • 22
  • 44
  • tag works on mediawiki only if i place ```$wgRawHtml=true``` in my LocalSettings.php file. Do you know of any other alternative? – rapito Aug 23 '19 at 15:16
0

<noscript> isn't even necessary, and it is not supported in XHTML

You can initially set the class to .scriptonly{display:none;}. Then you can add fillowing code, which will only be executed if user has enabled javascript, otherwise it will be ignored. You can toggle style properties if desired.

<script type="text/javascript">
     document.querySelectorAll(".scriptonly").style.display="block";
</script>
0

Hide element #foo from clients which have javascript:

html.client-js #foo { display: hidden; }

Hide element #foo from clients which do not have javascript:

html.client-nojs #foo { display: hidden; }
Tgr
  • 27,442
  • 12
  • 81
  • 118