Entry
How can I detect whether JavaScript is enabled?
Aug 19th, 2005 03:54
Abolfazl Shirazi, Martin Honnen, Abolfazl Shirazi
Obviously when JavaScript is disabled it can't detect whether it is
enabled. But there are some ways to support you in your page design to
distinguish JavaScript enabled and not enabled browsers.
First there is the
NOSCRIPT
tag that allows you to provide content for browsers not capable of
JavaScript or with JavaScript disabled. So
<NOSCRIPT>
This site requires JavaScript to be fully enjoyed.
</NOSCRIPT>
to display a message to those not using JavaScript is always possible.
You can even combine that with a META refresh tag that forwards to a
non JavaScript version of your page:
<HTML>
<HEAD>
<NOSCRIPT>
<META HTTP-EQUIV="refresh" CONTENT="1; URL=nonJsMainPage.html">
</NOSCRIPT>
</HEAD>
Or you keep the non JavaScript version as the starting page people come
to and include
<SCRIPT>
location.href = 'jsEnabledMainPage.html';
</SCRIPT>
in it so visitor with js enabled browsers get forwarded.
---------------------------------------
Abolfazl Shirazi :
I think You can do this work more easily. The function below
check whether javascript is enable or not .
<html>
<head>
<script>
function Check() {
if (navigator.JavaEnabled()) {
alert("The javascript is available .")
}
else {
return false
}
}
</script>
</head>
<body onload="Check()">
</body>
</html>