Difference between revisions of "Jmol Applet/Browser Support"

From Jmol
Jump to navigation Jump to search
(HTML tag for the applet)
(Jmol Object rather than "applet")
 
(5 intermediate revisions 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.''
Line 7: Line 18:
  
 
=== Browser compatibility ===
 
=== Browser compatibility ===
The "isFullyCompliant" test includes both "isBrowserCompliant" and "isJavaCompliant".
+
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.
+
''isJavaCompliant'' just checks if ''navigator.javaEnabled()'' returns true or false.
  
"isBrowserCompliant" works basically in this way:
+
''isBrowserCompliant'' works basically in this way:
* If "document.getElementById" exists, then "isBrowserCompliant" passes.
+
* If ''document.getElementById'' exists, then ''isBrowserCompliant'' will be true.
 
* Exceptions:
 
* Exceptions:
 
** Linux/Unix Konqueror ≤3.3
 
** Linux/Unix Konqueror ≤3.3
Line 22: Line 35:
 
Caveats:
 
Caveats:
 
* Detection is mostly based on [[:en:Browser Sniffing|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.
 
* Detection is mostly based on [[:en:Browser Sniffing|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)
+
* 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 ===
 
=== HTML tag for the applet ===
Line 28: Line 41:
  
 
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.
+
# Use an <code><applet></code> tag <sup>(Note 1)</sup>
# Use an <code><object></code> tag adequate for MS Internet Explorer.
+
# 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.
+
# Use an <code><object></code> tag adequate for other browsers <sup>(Note 3)</sup>
  
The general idea is that <code><object></code> is recommended over <code><applet></code>. (However, Sun/Oracle still advises to use <code><applet></code> due to irregular support of <code><object></code> by browsers.)
+
The general feeling is that <code><object></code> is recommended over <code><applet></code>. (However, Sun/Oracle still advises to use <code><applet></code> due to irregular support of <code><object></code> by browsers.)
 
Following this trend, {{file|Jmol.js}} uses the <code><object></code> tag whenever it is supported by the browser. ''However'', due to incomplete (or rather, not up-to-date) browser detection in {{file|Jmol.js}}, modern browsers like Chrome and Windows Safari end up using the fall-back <code><applet></code> tag.
 
Following this trend, {{file|Jmol.js}} uses the <code><object></code> tag whenever it is supported by the browser. ''However'', due to incomplete (or rather, not up-to-date) browser detection in {{file|Jmol.js}}, modern browsers like Chrome and Windows Safari end up using the fall-back <code><applet></code> tag.
  
Line 51: Line 64:
 
* as far as possible, detection is based on features and not on browser names (userAgent)
 
* 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.
 
* 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.
 +
 +
 +
<big>__'''''Notes'''''__</big>
 +
 +
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='<nowiki>http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab</nowiki>'
 +
>
 +
[...]
 +
</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>

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

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:

  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.


__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>

Contributors

AngelHerraez