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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is client javascript turned on?

Status
Not open for further replies.

bigoldbulldog

Programmer
Feb 26, 2002
286
US
Hello -

How do I tell if the client browser has javascript turned on?

Great thanks,
ND [smile]
 
it depends. In what situation?

If you make them log in to a page you can use something like this :

<body onload=&quot;document.submitForm.jsOn.value = true&quot;>

<form name=submitForm>
<input type=hidden name=jsOn value=false>

Then when the form is submitted as your user log in you can see wether or not JS is supported.

There is also the noscript tag that you might want to check out. Gary Haran
 
You have to use something other than Javascript to see if Javascript is turned on or not. If it's not, then the Javascript won't run to tell you it's not because the capabilities won't exist. You'll have to use some server side scripting to check this.

However, in this day and age, anyone who doesn't have Javascript turned on in their browser won't be able to do much at very many sites anyway. If you look at all the commercial websites that rely on Javascript for something significant in displaying things on the pages, you'll see most places DO use it. Anyone without Javascript turned on in their browser is going to either be used to or expecting seeing very little on the Internet, or so absolutely clueless they're not going to know the difference.
 
Using xutopia's idea, you could have the page redirect itself on loading IF Javascript is enabled, otherwise the viewer will get a page that says they can't see the site without Javascript enabled:

<html>
<script language=&quot;javascript&quot;>
location.href=&quot;json.htm&quot;
</script>

<body>
<center>You cannot view this site without Javascript enabled.</center>

</body>
</html>
 
Thank you for the responses. I neglected to say that I am working with ASP and want to discriminate the types of pages I return (with or without javascript).

ND
 
In the Browser object, there's a javascript property set to true if Javascript is enabled, and false if it isn't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top