I was puzzled with a question. Many browsers like Internet Explorer allows to disable the javascript.
How do I check through whether the user's Browser has disabled javascript or not?
I was puzzled with a question. Many browsers like Internet Explorer allows to disable the javascript.
How do I check through whether the user's Browser has disabled javascript or not?
An approach that e.g. modernizr uses is that you set a class no-js
and modernizr then removes that class after finishing.
In addition to pdeurstler's answer, there is an old school way.
It is tad old school but, <noscript>...</noscript>
detects JavaScript being disabled and executes the embed HTML.
A common solution is to the meta
tag in conjunction with noscript
to refresh the page and notify the server when JavaScript is disabled, like this:
<!DOCTYPE html>
<html lang="en">
<head>
<noscript>
<meta http-equiv="refresh" content="0; /?javascript=false">
</noscript>
<meta charset="UTF-8"/>
<title></title>
</head>
</html>
In the above example when JavaScript is disabled the browser will redirect to the home page of the web site in 0
seconds. In addition it will also send the parameter javascript=false
to the server.
A server side script such as node.js or PHP can then parse the parameter and come to know that JavaScript is disabled. It can then send a special non-JavaScript version of the web site to the client.
Just have some text that says you need javascript to use the site, then onload destroy that text with javascript.