How to check whether javascript is enabled in the browser

A

Anees

Hi,

I have some unavoidable javascript code in my page.
so if a user opens the page in a javacript disabled browser my page
will be completely messed up!!!!
how can i prevent this?

i know it might hav been answered already before,
if so.. please give the link to der
i do tried by searching it here, but i didnt get anything

Please help
Regards,
Anees
 
R

RobG

Anees said:
Hi,

I have some unavoidable javascript code in my page.
so if a user opens the page in a javacript disabled browser my page
will be completely messed up!!!!
how can i prevent this?

Design your page so that anyone visiting it without script support will
still get a functional page (even though it may not be fully functional,
it should still "work"). You can use a noscript element to advise that
javascript is required for full site functionality (there are other
strategies too).

It is generally frowned upon to *require* javascript for a public web
site. Your pages should be functional without javascript and only use
it to improve usability.
 
T

Thomas 'PointedEars' Lahn

Anees said:
I have some unavoidable javascript code in my page.
so if a user opens the page in a javacript disabled browser my page
will be completely messed up!!!!

BAD. Broken as designed.
how can i prevent this?

By applying the principle of graceful degradation in the first place: don't
have the basic functionality of the document and Web site depend on enabled
client-side script support, but only provide additional features with it.

Quite obviously you can not check with scripting if script support is
present and enabled, or not; that would be like using a possibly defective
light bulb to see if there is a current on the circuit. You can only check
whether the light bulb lights up assuming that there is a current on the
circuit[1], i.e. you can do something if script support is present and
*enabled*, and you just don't do that if it isn't, e.g.

<body
onload="/* only executed with present and enabled script support */">

<a href="foo.html"
onclick="/* only executed with present and enabled script support */">

<script type="text/javascript">
// this is only executed if script-support is present and enabled
document.write('<input type="button" value="Foo" onclick="foo();">');
</script>

The HTML 4.01 Specification also defines the `noscript' element which can be
used for alternative content to be displayed in the case that client-side
script support is not available. But you should use it carefully.
Certainly do not use it for the following:

<noscript>
Your browser does not support JavaScript. ...
</noscript>

Because that is not necessarily true. Your user may have the light bulb
screwed in and it would light up if there was current on the circuit (i.e.
*present* script support would be *enabled*), but there isn't.


BTW: Your Exclamation Mark key is broken.


PointedEars
___________
[1] as all examples go, they may not fit the situation exactly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top