check javascripr enable/disable

A

Anshul

I want to check through perl whether javascript is enabled or disabled
in mozilla browser. If it is disabled I want to display a message to
user to enable it. What code can I use please help.

I tried "navigator.javaEnabled() but it is in javascript again. If
javascript will be disabled so browser can neither read this code
even.

Thanks
 
T

Thomas 'PointedEars' Lahn

Anshul said:
I want to check through perl whether javascript is enabled or disabled
in mozilla browser.

You would need to use client-side scripting to submit an HTTP request
that is handled by the server-side Perl script if client-side script
support is enabled. For example:

<script type="text/javascript">
var img = new Image();
img.src = "http://foo.example/bar.pl?js=1";
</script>

Or, for another example, you could use XMLHttpRequest/IXMLHTTPRequest
for that. All solutions (have to) use a host object, and neither one is
guaranteed to be supported.
If it is disabled I want to display a message to
user to enable it. What code can I use please help.

Not possible using a server-side script without prior user interaction,
since it can only "know" when client-side script support is enabled as
the former has to be "notified" by the latter.
I tried "navigator.javaEnabled() but it is in javascript again. If
javascript will be disabled so browser can neither read this code
even.

You don't need any programming:

<noscript>...</noscript>

However, your approach is most likely wrong. Websites should work
without client-side script support.


PointedEars
 
A

Anshul

Anshul said the following on 7/30/2007 5:30 AM:



navigator.javaEnabled() tells you whether Java is enabled or not, not
whether JS is enabled or not.


<noscript>Please enable scripting in your browser</noscript>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Thanks Randy,

It helped me.

Bye
 
T

Thomas 'PointedEars' Lahn

Randy said:
Thomas 'PointedEars' Lahn said the following on 7/30/2007 5:49 AM:
Anshul said:
I want to check through perl whether javascript is enabled or disabled
in mozilla browser.
You would need to use client-side scripting to submit an HTTP request
that is handled by the server-side Perl script if client-side script
support is enabled. For example:
[...]
Or, redirect using JS.

Which could break the Back button.


PointedEars
 
P

Peter Michaux

I want to check through perl whether javascript is enabled or disabled
in mozilla browser. If it is disabled I want to display a message to
user to enable it. What code can I use please help.

I tried "navigator.javaEnabled() but it is in javascript again. If
javascript will be disabled so browser can neither read this code
even.

Thanks

There are many messages in the archives of this newsgroup describing
why a check for JavaScript being enabled or not is insufficient. This
will not tell you if you scripts will run successfully.

<URL: http://www.jibbering.com/faq/faq_notes/not_browser_detect.html>

Peter
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top