Difference between revisions of "Jmol Applet/Browser Support"
AngelHerraez (talk | contribs) (→HTML tag for the applet) |
AngelHerraez (talk | contribs) (→HTML tag for the applet) |
||
Line 28: | Line 28: | ||
In summary, there are 3 ways an applet can be inserted into an html page: | In summary, there are 3 ways an applet can be inserted into an html page: | ||
− | # Use an <code><applet></code> tag <sup>( | + | # Use an <code><applet></code> tag <sup>(Note 1)</sup> |
# Use an <code><object></code> tag adequate for MS Internet Explorer <sup>(Note 2)</sup> | # Use an <code><object></code> tag adequate for MS Internet Explorer <sup>(Note 2)</sup> | ||
# Use an <code><object></code> tag adequate for other browsers <sup>(Note 3)</sup> | # Use an <code><object></code> tag adequate for other browsers <sup>(Note 3)</sup> | ||
Line 53: | Line 53: | ||
− | |||
<big>__'''''Notes'''''__</big> | <big>__'''''Notes'''''__</big> | ||
Line 71: | Line 70: | ||
[...] | [...] | ||
</object> | </object> | ||
+ | :The 1.5.0 should probably be updated to a url giving 1.6 | ||
Note 3 - object tag for other browsers: | Note 3 - object tag for other browsers: |
Revision as of 18:45, 1 December 2010
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.
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)
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>