JSmol Deployment Local

From Jmol
Revision as of 11:52, 11 August 2025 by AngelHerraez (talk | contribs) (updates to remove methods for Java applet)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page summarizes some advice on how JSmol within web pages can be used to work from a local disk (file:// protocol), instead of from a web server (http:// protocol).

This section is in relation to JSmol, versions 14 and later, particularly. It only relates to HTML5 file access, and only to files loaded using script commands such as load and script.

Note that you can prompt the page visitor for a local file by using the Jmol script command load ? or a URL using load http://?.

Specific browser considerations

Firefox / Windows

You will be able to read both binary and text files locally, but it is necessary to change the default setting:

  • navigate to about:config, find the security.fileuri.strict_origin_policy entry and set it false.

Despite this, there may be occasions where access fails with errors, depending of the folder location of files composing the page and the JSmol library. (No certain description of setups that fail has been found yet)

Chrome / Windows

The old method of starting Chrome using the command-line flag --allow-file-access-from-files for local file access is no longer possible.

The only likely solution if you wish to use Chrome is to set-up a local web server (read below).

It is not possible to load local binary files from standard script commands. That is, no direct file reading with any of the following in their names:

 .bin .gz .jmol .jpg .map .mrc .omap .png .pse .smol .spartan .zip

This does not apply to files drag-dropped onto JSmol or files loaded using "?", which use the HTML5 FileReader object. That method reads binary files without a problem.

Edge / Windows

Situation is the same as for Chrome (pending confirmation)

Opera / Windows

to-do

Firefox / Mac

to-do

Chrome / Mac

to-do

Safari / Mac

to-do

Using a local web server

Several packages are available that will install a local server in your system. You will then be able to access your local pages and molecule files by activaning such server and access the pages via localhost: or http://127.0.0.1/ protocols.

This removes any limitations in accessing files. Note that for binary files, at least with some browsers, you need to configure the serverURL item in the Info variable to use the PHP filter, likely from the same server.

As an easier alternative, there seems to be some extensions for the Chrome browser that will act as local server. Compatibility with latest Chrome security policies has not been checked.

Legacy documentation

Mainly involving use of Jmol Java Applets in web pages (not supported by current web browsers)

See the old version of this page.