Difference between revisions of "Troubleshooting/Local Files"

From Jmol
Jump to navigation Jump to search
(moving local file access tricks to Troubleshoot sction)
(using local files in browsers)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= Accessing J(S)mol-containing webpages in local disk, or loading models from local files =
 
= Accessing J(S)mol-containing webpages in local disk, or loading models from local files =
 +
 +
== Symptoms ==
 +
When trying to load a page, some of these error warnings are shown in an alert box:
 +
 +
[[File:Local file error.png|border|center]]
  
 
== MacOS ==
 
== MacOS ==
Line 17: Line 22:
 
(Make sure an instance of Chrome is not active when you issue that command.)
 
(Make sure an instance of Chrome is not active when you issue that command.)
  
There is possibly a way to write an AppleScript to do this in one fell swoop.
+
There is possibly a way to [[Troubleshooting/Local_Files/MacChromeAutomator|write an AppleScript]] to do this in one fell swoop.
  
 
== Windows ==
 
== Windows ==
  
 
=== Firefox ===
 
=== Firefox ===
You will be able to read both binary and text files locally. Please enter <code>about:config</code> in the url address slot and then set <code>security.fileuri.strict_origin_policy false</code>.
+
You will be able to read both binary and text files locally. Please enter <code>about:config</code> in the url address slot and then try setting as '''<code>false</code>''' one of these:
 +
security.fileuri.strict_origin_policy
  
 
=== Chrome ===
 
=== Chrome ===
If you need to open local files, start Chrome using the command-line flag <code>--allow-file-access-from-files</code>. Beyond that, same as for MSIE/Windows below.
+
If you need to open local files, first close all instances of Chrome and then try starting Chrome (from a command line or a shortcut) with one of these options:
 +
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
 +
 
 +
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="C:\Users\my-user-name\Documents"
 +
...or specifying as <code>user-data-dir</code> wherever you have your html, JSmol and molecular files in your local disk.
  
=== MSIE ===
 
 
It is '''not''' possible to load local '''binary''' files into JSmol/HTML5 from standard script commands. That is, no direct file reading with any of the following in their names:
 
It is '''not''' possible to load local '''binary''' files into JSmol/HTML5 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 the Jmol object or files loaded using "?", which use the HTML5 FileReader object. That method reads binary files without a problem.
  
  .bin .gz .jmol .jpg .map .mrc .omap .png .pse .smol .spartan .zip
+
=== MSIE ===
 +
''Note: nowadays, you should avoid using MSIE for pages with JSmol. Its performance is much poorer and compatibility with some features is limited.''
  
This does not apply to files drag-dropped onto the Jmol object or files loaded using "?", which use the HTML5 FileReader object. That method reads binary files without a problem.
+
The same limitations apply regarding local '''binary''' files as those explained above for Chrome.

Latest revision as of 18:48, 17 December 2020

Accessing J(S)mol-containing webpages in local disk, or loading models from local files

Symptoms

When trying to load a page, some of these error warnings are shown in an alert box:

Local file error.png

MacOS

Safari

Symptom: trying to load an html file with JSmol/Java in Safari. The applet tries to load but then fails.

Solution: Safari > Preferences > Advanced > check the Show Develop menu in menu bar option.
In the resulting Develop toolbar drop-down, check the Disable Local File Restrictions option.

Caveat: when models in binary-format files are to be loaded, Safari may fail in any case for local files.

Chrome

A command entered in the terminal allows to start up MacOS Chrome so that JSmol runs from local files:

open /Applications/Google\ Chrome.app --args --allow-file-access-from-files

(Make sure an instance of Chrome is not active when you issue that command.)

There is possibly a way to write an AppleScript to do this in one fell swoop.

Windows

Firefox

You will be able to read both binary and text files locally. Please enter about:config in the url address slot and then try setting as false one of these:

security.fileuri.strict_origin_policy

Chrome

If you need to open local files, first close all instances of Chrome and then try starting Chrome (from a command line or a shortcut) with one of these options:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-web-security --user-data-dir="C:\Users\my-user-name\Documents"

...or specifying as user-data-dir wherever you have your html, JSmol and molecular files in your local disk.

It is not possible to load local binary files into JSmol/HTML5 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 the Jmol object or files loaded using "?", which use the HTML5 FileReader object. That method reads binary files without a problem.

MSIE

Note: nowadays, you should avoid using MSIE for pages with JSmol. Its performance is much poorer and compatibility with some features is limited.

The same limitations apply regarding local binary files as those explained above for Chrome.

Contributors

AngelHerraez