Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifiying if browser has JavaScript disabled

Status
Not open for further replies.

GezH

Programmer
Aug 7, 2002
68
Hello,

How can I tell (using either HTML or JSP) whether a user has their JavaScript disabled in the browser?

I'm developing an application and want to direct users to a different page depending upon that.

Many thanks.
 
Just putting your question title in Google will show you the answer.

Cheers,
Dian
 
Hi

Only the browser can tell if JavaScript is available and enabled. To send such information to the server you can do something like this :
Code:
[gray]...[/gray]
<head>
<meta http-equiv="refresh" content="3;url=whatever.jsp?js=no">
<script type="text/javascript">
window.location.href='whatever.jsp?js=yes;
</script
</head>
[gray]...[/gray]
Although the preferred way is to simply do a JavaScript independent site, then enhance it with optional JavaScript code.

Feherke.
 
Many thanks feherke, that was just what I was after.
 
Some newer browsers, like IE7, have Meta refreshes disabled by default (at least in mine it was). I'd add in a link for the user to click if the redirect is unsuccessful.

So to expand on Feherke's example...
Code:
<head>
<meta http-equiv="refresh" content="3;url=whatever.jsp?js=no">
<script type="text/javascript">
window.location.href='whatever.jsp?js=yes;
</script>
[b]<noscript>
<a href="whatever.jsp?js=no">Please visit our new site</a>
</noscript>[/b]
</head>

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top