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
+6.6k Golang : Embedded or data bundling example
+87.8k Golang : How to convert character to ASCII and back
+9k Golang : Populate or initialize struct with values example
+17.7k Golang : Read data from config file and assign to variables
+16.4k Golang : Send email and SMTP configuration example
+8.2k Golang : Find relative luminance or color brightness
+18.8k Golang : Delete duplicate items from a slice/array
+14.5k Golang : Find network of an IP address
+9.6k Golang : How to generate Code 39 barcode?
+14k Golang : concatenate(combine) strings
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+10.6k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery