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
+13.2k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+20.1k Golang : How to get struct tag and use field name to retrieve data?
+7.2k Ubuntu : connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
+12.5k Golang : Arithmetic operation with numerical slices or arrays example
+21.1k Golang : How to force compile or remove object files first before rebuild?
+7.2k Golang : How to iterate a slice without using for loop?
+11.2k Golang : Byte format example
+13.3k Golang : Verify token from Google Authenticator App
+7.1k Golang : Get environment variable
+16k Golang : Get sub string example
+9k Golang : Get curl -I or head data from URL example
+52.4k Golang : How to get struct field and value by name