Is that possible?
before entering a site, it should check whether java is installed and it has to be of a specific version before redirecting to the designated page.
javascript cannot be used because it c开发者_如何学Can be turned off by the user.
java applet cannot be used to check as it can disabled by the userthank you.
I think it is naive to assume that someone would have JS disabled but Java installed & enabled.
- JS comes with the browser, but Java does not.
- JS is enabled by default, and has to be explicitly disabled.
- Many sites today either rely on JS, or give a much slicker user experience when JS is enabled.
- The deployJava.js is the latest strategy offered by Sun/Oracle for checking that a browser has a specified minimum version of Java before running an applet or including a launch link for JWS applications. If 90% of deployers of applets in the last 2-3 years use the script, what do you think the chances are of seeing Java installed and enabled in those browsers where JS is disabled?
Sun's former way of ensuring an applet had a necessary version of the plug-in was using
HTMLConverter, which produced the nested OBJECT
/EMBED
element so hated by validation services
(and any self respecting web developer). This invalid HTML used no JS or Java to do what it did,
it all relied on HTML & the browser/user's ability and willingness to act on the said elements.
However I do not recommend using that approach, I think deployJava.js is a better way to achieve it.
If you are truly insistent on making every attempt to determine the user's Java, and do not mind 'breaking the back button', there are other techniques that can be used. E.G. have a series of pages.
- The first page has a meta-refresh redirect to
nojs.html
set at NN seconds and uses JS to redirect tohasjs.html
immediately. - The
hasjs.html
tests for Java:- Detect if Java is enabled
- Check Java version using something along the lines of
javascript:alert(java.lang.System.getProperty('java.version'))
. It works in the address bar of FF to pop a dialog that reports1.6.0_24
on this box. - (Finally) to determine that the applet itself is active (as opposed to crashed/refused at run-time), see Detect if an Applet is ready.
So as can be seen, JS will not only be able to check if Java is enabled, but can also check the version & that any specific applet has loaded successfully.
You can prompt the user to input which version of Java they have installed. Otherwise, no.
Well, without using Java Applet and without using JavaScript. What else can you use? You are trying to access client specific data, you can't grab such data in the server side.
Rewrite your application in .NET, and then you can enjoy User-Agent lines like this:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;
.NET CLR 1.1.4322; .NET CLR 2.0.50727)2011-04-27 23:02:21
I wish browsers were sending same stuff for installed Java... alas, they don't.
精彩评论