Javascript : How to show different content with noscript?
Problem :
You got complains from your website visitors that certain functions or part of your website is not functioning or displaying correctly. Such as checkout cart or login button missing.
Upon investigation, you found out that it is because of the the visitors' browser having JavaScript turned-off or some extension blocked JavaScript from loading properly.
So, how do you inform the visitors to enable JavaScript or turn off the extension?
Solution :
Use the HTML noscript
tag to detect if the visitor's browser JavaScript is turned off or blocking JavaScript from executing.
Example of noscript
tag in action :
Example of JavaScript page loading properly :
Here is the code :
NOTE : Just a reminder, that for security reason... you cannot force or turn on JavaScript on a browser with code. You can only remind the user and ask them - politely - to turn on the JavaScript engine for you.
Hope this tutorial can be useful to you.
See also : Javascript : How to get width and height of a div?
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+11.9k How to automatically restart your crashed Golang server
+5.9k Android Studio : AlertDialog to get user attention example
+8.7k Golang : Convert file unix timestamp to UTC time example
+8.2k Golang : Sort and reverse sort a slice of integers
+12.6k Golang : Get URI segments by number and assign as variable example
+7.7k Golang : Timeout example
+4.4k Golang : Denco multiplexer example
+7.3k Golang : Get curl -I or head data from URL example
+11.4k Golang : Read XML elements data with xml.CharData example
+13.2k Golang : Force download file example
+17.7k Golang : Delete item from slice based on index/key position
+9.2k Golang : Natural string sorting example