473,597 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find out if Javascript is enabled

Is there any way to find out programmaticall y if Javascript is
supported/enabled in a browser? By "programmatical ly" I mean on the Java
servlet side.

TIA

Alex Molochnikov
Gestalt Corporation
Jul 23 '05 #1
13 8456
Alex Molochnikov wrote:
Is there any way to find out programmaticall y if Javascript is
supported/enabled in a browser? By "programmatical ly" I mean on the Java
servlet side.

TIA

Alex Molochnikov
Gestalt Corporation

Java has nothing to do with Javascript, so consider this:- On your own
PC, could you run an Algol program to find out if ADA was working?
Course not.
Jul 23 '05 #2
Mark,
Java has nothing to do with Javascript
I lost count how many times I gave this very advice to the newbies who
mistakenly wandered into Java NGs and asked questions about Javascript. But
the question was about Java servlets _discovering_ the status of Javascript.

Java servlets are capable of determining if cookies are enabled on the
client's browser. The browser is also capable of sending a parameterized
request to the servlet, passing any info. In fact, if my question was about
discovering something _other_ than Javascript, I would have used Javascript
to get the info and pass it to the servlet. Unfortunately, in this
particular case, I cannot do so for the obvious reason.
On your own PC, could you run an Algol program to find out if ADA was working? Course not.


The question was not about Javascript "working". It was about the Javascript
option being enabled or disabled in the _browser_, and the Java servlet
finding it out.

Perhaps, your answer should have been: "I don't know", but then you could
have simply ignored the post.

AM
Jul 23 '05 #3
"Alex Molochnikov" <NO****@NOSPAM. COM> wrote in message
news:wiuJd.1694 82$Xk.89165@pd7 tw3no...
Perhaps, your answer should have been: "I don't know", but then you could
have simply ignored the post.


And here is the answer:

<noscript>
<META HTTP-EQUIV="Refresh" CONTENT="0;
URL=Callback?JA VASCRIPTSTATUS= NONE">
</noscript>

"Callback" is the name of the servlet. Its doGet() method gets called when
the page loads and executes the <noscript> tag. The JAVASCRIPTSTATU S
parameter carries the value ("NONE") to the servlet.

My sincere thanks to everyone who looked at my inquiry, even though nobody
responded with a constructive answer.

AM
Jul 23 '05 #4
Alex Molochnikov wrote:
Alex Molochnikov wrote:
Perhaps, your answer should have been: "I don't know", ...
<snip> And here is the answer:

<noscript>
<META HTTP-EQUIV="Refresh" CONTENT="0;
URL=Callback?JA VASCRIPTSTATUS= NONE">
</noscript> <snip>

This testing strategy does not answer your stated question. It may give
an indication that a client has scripting disabled/unavailable, but only
when that client also supports, and acts upon, <META
HTTP-EQUIV="Refresh" ... . As many modern browsers allow META refresh to
be disabled independently of (but obviously in addition to) javascript
the strategy risks giving an indication that scripting is enabled on the
client when in fact it is not. Generally erring in that direction should
be less desirable than erroneously assuming scripting is disabled when
in fact it is available.

However, the formal rules of HTML categorise META elements as
"head.misc" and makes the only valid location for such an element a
direct child of the HEAD element, while NOSCRIPT elements are "block"
elements and may only be descendants of the BODY element. Thus in valid
HTML a META element cannot be a child of a NOSCRIPT element. The two are
only allowed in mutually exclusive contexts. As a result this code will
also potentially give a false indication of client-side script support
on browsers that take a more literal interpretation of HTML, or apply
realistic error-correction rules.

It is always a bit depressing to be reminded of the actual number of
individuals working in the production of HTML who have little or no
technical understanding of HTML.

With the NOSCRIPT element in its correct context within the BODY it
should still be possible to make a GET request to a servlet. Placing an
IMG element, or an IFRAME element within the NOSCRIPT element would
result in valid HTML and encourage the browser to make the desired GET
request. But again, false indications of client-side script support
would be generated by browsers with images turned off, or incapable of
supporting IFRAMEs.
My sincere thanks to everyone who looked at my inquiry,
even though nobody responded with a constructive answer.


According to my newsreader you have allowed less than 13 hours for a
reply. On an international group it takes 24 hours for all of the
contributors to even see the original massage, let alone respond. But it
is quite likely that you haven't received any "constructi ve" responses
before now because everyone knows that there is no 100% reliable method
of acquiring the information that you have stated that you want, and the
chances are extremely slim that the information you claim to want is
actually the information you need. Though with little browser scripting
experience it is unlikely that you will see that, even if someone took
the time to explain why.

Richard.
Jul 23 '05 #5
"Richard Cornford" <Ri*****@litote s.demon.co.uk> wrote in message
news:ct******** ***********@new s.demon.co.uk.. .
It is always a bit depressing to be reminded of the actual number of
individuals working in the production of HTML who have little or no
technical understanding of HTML. [...] But it
is quite likely that you haven't received any "constructi ve" responses
before now because everyone knows that there is no 100% reliable method
of acquiring the information that you have stated that you want, and the
chances are extremely slim that the information you claim to want is
actually the information you need.
Your response to my post, with the given explanations, would have been a lot
more productive, if you did not adopt the condescending tone, bordering on
insult. Making assumptions about how much I understand of my own needs is
arrogant, to put it mildly. Your other assumption about the desire for "100%
reliability" is not supported by my original post. I have been programming
since 1975, do it for the living, and do not need to be lectured about the
lack of 100% reliable solutions. And what I am working on is not a
"production HTML" at all - this is another one of your baseless assumptions.
Though with little browser scripting
experience it is unlikely that you will see that, even if someone took
the time to explain why.


Nevertheless, you attempted to do just that - I wonder, if you were tempted
by an opportunity to show off your superior knowledge of the subject, or did
it for the pleasure of putting me down.

I have been in this business long enough to know that all software products
are compromises, never reaching the originally stated goal, yet delivering
working solutions to the users. And through the years of hands-on
experience, I also learned that there is no such thing as "no solution". The
only impediment to finding the solution is the constraints of someone's
mind.

I do not expect an apology from you, nor do I need one. It will suffice if
you simply stay away from this thread, letting other people answer my
question, without insulting me.

AM
Jul 23 '05 #6
Alex Molochnikov wrote:
"Alex Molochnikov" <NO****@NOSPAM. COM> wrote in message
news:wiuJd.1694 82$Xk.89165@pd7 tw3no...
Perhaps, your answer should have been: "I don't know", but then you could
have simply ignored the post.

And here is the answer:

<noscript>
<META HTTP-EQUIV="Refresh" CONTENT="0;
URL=Callback?JA VASCRIPTSTATUS= NONE">
</noscript>

"Callback" is the name of the servlet. Its doGet() method gets called when
the page loads and executes the <noscript> tag. The JAVASCRIPTSTATU S
parameter carries the value ("NONE") to the servlet.

My sincere thanks to everyone who looked at my inquiry, even though nobody
responded with a constructive answer.

That is certainly a means of informing the Java servelet of the current
Javascript capability of the browser (provided the browser supports the
<META> option, of course). However, it is actually the *reverse* of what
you asked for.

Here, you are using the browser to tell the Java what it can do. What
you asked for was for the Java to find the browser and work out for
itself what it could do. It may be that I misunderstood your question
with its stress on working on the servelet-side, but here you are
clearly doing the work on the client-side.

It may have been better for the question to be a bit more expressive so
that such confusion could be avoided.
Jul 23 '05 #7
"Mark Preston" <us****@nosourc e.co.uk> wrote in message
news:ct******** ***********@new s.demon.co.uk.. .
That is certainly a means of informing the Java servelet of the current
Javascript capability of the browser (provided the browser supports the
<META> option, of course).
I tested this under IE6, NN7, Firefox and Mozilla (Linux). It works.
Collectively, these 4 browsers make up 93% of the today's market, so I am
not going to worry about the rest.
It may have been better for the question to be a bit more expressive so
that such confusion could be avoided.


Possibly so. It was clear in my mind when I wrote it, that I wanted to get
the info from the browser and pass it to the servlet. After re-reading my
post, I see that it could be interpreted as getting the info on the servlet
side, without any involvement of the browser.

Anyway, thank you for the comments. I will try to spell things out in more
detail when I post again.

Regards,

Alex.
Jul 23 '05 #8
JRS: In article <ct************ *******@news.de mon.co.uk>, dated Tue, 25
Jan 2005 13:49:18, seen in news:comp.lang. javascript, Mark Preston
<us****@nosourc e.co.uk> posted :
Alex Molochnikov wrote:
Is there any way to find out programmaticall y if Javascript is
supported/enabled in a browser? By "programmatical ly" I mean on the Java
servlet side.

TIA

Alex Molochnikov
Gestalt Corporation

Java has nothing to do with Javascript, so consider this:- On your own
PC, could you run an Algol program to find out if ADA was working?
Course not.

Please trim sigs.

I have no Algol here; but I can run a Pascal program to determine
whether Delphi is working (with the relationship between the languages
being inconsequential ). Pascal writes a simple Delphi program
begin Writeln(1*2*3*4 *5*6*7*8*9) end.
to file, uses Exec to compile it with DCC32 -cc <file> and then to
run it; and then does screen capture to look for "362880" or "Bad
command or file name". Or Delphi could write to file.
A browser could use VBScript to set a variable, then javascript to
change it, then VBscript to read it. If javascript was not enabled,
human intervention would be needed.
The usual way is to have the entry page use javascript to jump to
another page; if you get there, it worked. The calling page can set a
parameter, such as new Date().getTime( ), and the destination can check
for approximate correctness, as a moderate defence against direct entry
to the second page; the parameter can be obfuscated.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #9
Alex Molochnikov wrote:
"Mark Preston" <us****@nosourc e.co.uk> wrote in message
news:ct******** ***********@new s.demon.co.uk.. .
That is certainly a means of informing the Java servelet of the current
Javascript capability of the browser (provided the browser supports the
<META> option, of course).

I tested this under IE6, NN7, Firefox and Mozilla (Linux). It works.
Collectively, these 4 browsers make up 93% of the today's market, so I am
not going to worry about the rest.


Open IE6
Tools>Internet Options>Securit y Tab>Advanced Options.
Scroll down to the Miscellaneous Section.
Second option is to Enable/Disable META REFRESH.

Meta Refresh is just as simple to disable in IE as script is.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1828
by: Christian Ista | last post by:
Hi, Is it possible to check if the javascript is turn on on the browser (IE, firefox, ...)? Thanks, Christian,
9
3053
by: SHarris | last post by:
Hello, In our new intranet ASP.NET project, two requirements are that the browser accept cookies AND JavaScript. We are requiring the use of Internet Explorer 6+. 1. Using C# in an ASP.NET application, how can we code the project to check to make sure the browser accepts cookies? 2. Where would we put this code? In Global.asax? 3. Using C# in an ASP.NET application, how can we code the project to detect and make sure the browser...
10
1917
by: David Thielen | last post by:
Hi; When a user clicks a radio button, what I would like to do is that if javascript is enabled on their browser, it calls a javascript function and does not do a postback. If javascript is disabled, then it does do a postback. Is there a way to do this? -- thanks - dave
6
61594
by: Jim | last post by:
How do I check if javascript is enabled in PHP? TIA, Jim
8
2841
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :) >. I've read quite a few posts on how to do this, but none meet my need (the two main suggestions was set a jsEnabled variable in a <scriptsection of the HTML and read it in PHP, and the other suggestion was by default loading the non js page,...
3
2585
by: WayneH | last post by:
Hi - I'm trying to use javascript to determine if a user's browser has cookies enabled or not. To test: copy this code into a file with a 'html' extension, and load it into your IE browser directly, through a local web server and through a remote web server. By turning cookies on/off in your browser, running the file, then clicking the 'test1' or 'test2' buttons, the displayed text should accurately inform you if your cookies are On or...
3
1355
by: go4java | last post by:
Hi all, is there a way to find out (via Java) whether Users Internet browser has JavaScript enabled or not? Best rgds.
2
2107
by: mahamedha | last post by:
Hi Here I am using this line of code to know wether the java is disabled or enabled in IE. javaEnabled = window.navigator.javaEnabled(); It is working fine in mozilla fire fox but it is not working in IE. It always coming true.
12
2787
by: Anic297 | last post by:
Hi, This is certainly a simple question, but I'm a newbie in JavaScript. Is there a way to know if JavaScript is enabled? My php script uses JavasSript to do something. If JavaScript is not enabled, I can put a "submit" push button. But I don't want both (the "submit" push button with the automatic action), so I want to know on the fly which one I must use (whether JavaScript is enabled).
0
7962
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6681
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5844
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5423
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3880
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1229
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.