Jmol Applet/Browser Support

From Jmol
Revision as of 18:42, 1 December 2010 by AngelHerraez (talk | contribs) (HTML tag for the applet)
Jump to navigation Jump to search

Browser support for the Jmol applet using Jmol.js

This page tries to explain and document what the File icon.gifJmol.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.

File icon.gifJmol.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:

  1. Use an <applet> tag (Note 1)
  2. Use an <object> tag adequate for MS Internet Explorer (Note 2)
  3. 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, File icon.gifJmol.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 File icon.gifJmol.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 File icon.gifJmol.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.


<a name='notes'></a> __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>

Note 3 - object tag for other browsers:

<object 
   classid='java:JmolApplet'
   type='application/x-java-applet'
>
[...]
</object>

Contributors

AngelHerraez