Answered by:
how can I check whether user disabled js in browser options or not (to remind him not to)

Question
-
User283528319 posted
hi all,
how can I check whether user disabled js in browser options or not (to remind him not to)
Thursday, August 1, 2019 7:01 AM
Answers
-
User753101303 posted
Hi,
You could use https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript to show a warning message
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 1, 2019 7:07 AM -
User-719153870 posted
Hi fatihbarut,
There's a easy way that you can check if the user's browser allow JS and remind if not.
Please refer to below code in my demo:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <p id="Testjs">Please enable js in your browser!</p> </div> </form> </body> </html> <script type="text/javascript"> document.getElementById("Testjs").style.display = "none"; </script>
As you can see, just put the remind message in document and use js to hide it, if js is not allowed, this message will come out naturally.
Here's the result of this trick:
Block the js in chrome:
And you will see the message:
Allow js in chrome:
And the message is hidden:
Best Regard,
Yang Shen
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, August 2, 2019 6:09 AM
All replies
-
User753101303 posted
Hi,
You could use https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript to show a warning message
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, August 1, 2019 7:07 AM -
User283528319 posted
thanks but can it work with chrome?
Thursday, August 1, 2019 9:42 AM -
User753101303 posted
Sure. Any reason to think it shouldn't ? Try yourself and give details if you find it doesn't. I imagine one could write an extension that blocks scripts without reporting scripting is blocked maybe ???
Edit: if this is because it's on the Mozilla site note that there is a browser compatibility chart and see:
https://blogs.windows.com/msedgedev/2017/10/18/documenting-web-together-mdn-web-docs/Thursday, August 1, 2019 11:08 AM -
User-719153870 posted
Hi fatihbarut,
There's a easy way that you can check if the user's browser allow JS and remind if not.
Please refer to below code in my demo:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <p id="Testjs">Please enable js in your browser!</p> </div> </form> </body> </html> <script type="text/javascript"> document.getElementById("Testjs").style.display = "none"; </script>
As you can see, just put the remind message in document and use js to hide it, if js is not allowed, this message will come out naturally.
Here's the result of this trick:
Block the js in chrome:
And you will see the message:
Allow js in chrome:
And the message is hidden:
Best Regard,
Yang Shen
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, August 2, 2019 6:09 AM -
User283528319 posted
Hi fatihbarut,
There's a easy way that you can check if the user's browser allow JS and remind if not.
Please refer to below code in my demo:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <p id="Testjs">Please enable js in your browser!</p> </div> </form> </body> </html> <script type="text/javascript"> document.getElementById("Testjs").style.display = "none"; </script>
As you can see, just put the remind message in document and use js to hide it, if js is not allowed, this message will come out naturally.
Here's the result of this trick:
Block the js in chrome:
And you will see the message:
Allow js in chrome:
And the message is hidden:
Best Regard,
Yang Shen
thanks a lot, good trick, but what about the other easy way?
Friday, August 2, 2019 6:25 AM -
User753101303 posted
what about the other easy way?I tried in Chrome and it worked. Could you clarify which problem you have? You tried ?
Friday, August 2, 2019 7:32 AM