Jmol Applet/Browser Support

From Jmol

Jump to: navigation, search

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

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.

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


  • 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:

  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.


Note 1 - applet tag:

   archive='JmolApplet0.jar' codebase='yourPath'

Note 2 - object tag for MSIE:

The 1.5.0 should probably be updated to a url giving 1.6

Note 3 - object tag for other browsers:

Personal tools