Difference between revisions of "Jmol Applet/Browser Support"
AngelHerraez (talk | contribs) (→Browser compatibility) |
AngelHerraez (talk | contribs) (Jmol Object rather than "applet") |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | ''Note:'' | ||
+ | All this is even more obsolete now that the use of Jmol.js is deprecated with the new '''JSmol''' ([[Jmol JavaScript Object]]). | ||
+ | |||
+ | |||
+ | ''Note:'' | ||
+ | All that is written below is obsolete now. | ||
+ | On 30th January, 2011, a fix was applied to Jmol.js to correct a problem with the Chrome browser in MacOS. Also, browser detection routine was improved. | ||
+ | |||
+ | Until I found the time to put updtated info and explanations here, you can check the comments at | ||
+ | http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/appletweb/Jmol.js?r1=12775&r2=15071 | ||
+ | |||
== Browser support for the Jmol applet using Jmol.js == | == Browser support for the Jmol applet using Jmol.js == | ||
''This page tries to explain and document what the {{file|Jmol.js}} javascript library is doing to insert applets depending on the user's browser. It will hoepfully lead to discussion about future implementation.'' | ''This page tries to explain and document what the {{file|Jmol.js}} javascript library is doing to insert applets depending on the user's browser. It will hoepfully lead to discussion about future implementation.'' |
Latest revision as of 19:55, 6 September 2014
Note: All this is even more obsolete now that the use of Jmol.js is deprecated with the new JSmol (Jmol JavaScript Object).
Note:
All that is written below is obsolete now.
On 30th January, 2011, a fix was applied to Jmol.js to correct a problem with the Chrome browser in MacOS. Also, browser detection routine was improved.
Until I found the time to put updtated info and explanations here, you can check the comments at http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol/appletweb/Jmol.js?r1=12775&r2=15071
Browser support for the Jmol applet using Jmol.js
This page tries to explain and document what the Jmol.js javascript library is doing to insert applets depending on the user's browser. It will hoepfully lead to discussion about future implementation.
According to Jmol version 12.0.21.
Jmol.js runs some tests to anticipate browser compatibility and to decide how to insert the Jmol applet in the pages.
Browser compatibility
The isFullyCompliant test includes both isBrowserCompliant and isJavaCompliant.
The result of isFullyCompliant is used only in _jmolCheckBrowser(), which is called before generating applets or controls and warns the user if the browser is not compliant.
isJavaCompliant just checks if navigator.javaEnabled() returns true or false.
isBrowserCompliant works basically in this way:
- If document.getElementById exists, then isBrowserCompliant will be true.
- Exceptions:
- Linux/Unix Konqueror â¤3.3
- Mac Opera â¤7.54
- Mac Internet Explorer
- Mac Safari â¤1.2 (Webkit version â¤125.12)
- Mac Mozilla with Java â¤1.4.2
Caveats:
- Detection is mostly based on browser sniffing, which is in general terms a method not recommended to adapt web content to browsers. The rationale is probably that some specific browsers proved not to be compatible with Jmol, and that was the best way to detect them.
- Some (recent) browsers are therefore not being taken care of. (e.g. Safari in Windows, Chrome); however, these two are detected as Safari, do not fall into the listed exceptions and so they will pass the test. No problem!
HTML tag for the applet
The history of inserting Java applets in pages is long and complex, and there has been permanent debate over methods, standards and actual practice. Details will not be given here.
In summary, there are 3 ways an applet can be inserted into an html page:
- Use an
<applet>
tag (Note 1) - Use an
<object>
tag adequate for MS Internet Explorer (Note 2) - Use an
<object>
tag adequate for other browsers (Note 3)
The general feeling is that <object>
is recommended over <applet>
. (However, Sun/Oracle still advises to use <applet>
due to irregular support of <object>
by browsers.)
Following this trend, Jmol.js uses the <object>
tag whenever it is supported by the browser. However, due to incomplete (or rather, not up-to-date) browser detection in Jmol.js, modern browsers like Chrome and Windows Safari end up using the fall-back <applet>
tag.
These are the current rules:
- First, use the IE-specific
<object>
tag if- it is a Windows system and the browser is IE â¥5.5 (or it simulates to be, based on the 'msie' string in the userAgent)
- Otherwise, use a more generic HTML4
<object>
tag if- it's a Mozilla browser and not a Mac system
- or it's Windows Opera â¥8.0
- or it's a Mac Safari â¥2.0 (Webkit version â¥412.2) -- that usually matches Mac OS X v10.4
- Else, use an
<applet>
tag.
This leaves out Safari in Windows and Google Chrome --except maybe in the Mac (Chrome userAgent includes the 'Safari' keyword)--, which currently fall back to using the <applet>
tag.
Proposal: update the browser detection code in Jmol.js so that
- as far as possible, detection is based on features and not on browser names (userAgent)
- include Chrome and Win-Safari among the "HTML4" browsers --as well as any other browser whose detection is found to be mistaken; candidates are welcome.
__Notes__
Note 1 - applet tag:
<applet code='JmolApplet' archive='JmolApplet0.jar' codebase='yourPath' [...] mayscript='true' </applet>
Note 2 - object tag for MSIE:
<object classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' codebase='http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab' > [...] </object>
- The 1.5.0 should probably be updated to a url giving 1.6
Note 3 - object tag for other browsers:
<object classid='java:JmolApplet' type='application/x-java-applet' > [...] </object>