468,272 Members | 2,011 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

check javascripr enable/disable

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

Jul 30 '07 #1
6 3112
Anshul said the following on 7/30/2007 5:30 AM:
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.
navigator.javaEnabled() tells you whether Java is enabled or not, not
whether JS is enabled or not.
If javascript will be disabled so browser can neither read this code
even.
<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/
Jul 30 '07 #2
Anshul wrote:
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
Jul 30 '07 #3
Thomas 'PointedEars' Lahn said the following on 7/30/2007 5:49 AM:
Anshul wrote:
>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.
Or, redirect using JS.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 30 '07 #4
On Jul 30, 3:09 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Anshul said the following on 7/30/2007 5:30 AM:
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.

navigator.javaEnabled() tells you whether Java is enabled or not, not
whether JS is enabled or not.
If javascript will be disabled so browser can neither read this code
even.

<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

Jul 30 '07 #5
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 7/30/2007 5:49 AM:
>Anshul wrote:
>>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
Jul 30 '07 #6
On Jul 30, 2:30 am, Anshul <anshul...@gmail.comwrote:
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

Jul 30 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by vncntj | last post: by
2 posts views Thread by eddie wang | last post: by
reply views Thread by talal | last post: by
4 posts views Thread by John Salerno | last post: by
8 posts views Thread by rongchaua | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.