From e0869d1dbeebe23f4ec0047128aa1058076498c2 Mon Sep 17 00:00:00 2001 From: David von Oheimb Date: Sun, 8 Apr 2018 23:48:36 +0200 Subject: [PATCH] give error message on local file access only when access was denied, extending hint on possible workarounds --- src/standalone/standalone.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/standalone/standalone.js b/src/standalone/standalone.js index 328cb733..55b28237 100644 --- a/src/standalone/standalone.js +++ b/src/standalone/standalone.js @@ -84,6 +84,14 @@ function parseURLParameters() { configFromURL.escapeHTML = true; viewer = pannellum.viewer('container', configFromURL); }; + request.onerror = function(e) { + // Display error if opened from local file + if (window.location.protocol == 'file:') + anError('Due to browser security restrictions, loading Pannellum files from the local filesystem has been denied; ' + + 'use the Chrome/Opera command-line option "--allow-file-access-from-files" or some sort of local web server.'); + else + anError("Error loading "+configFromURL.config); + } request.open('GET', configFromURL.config); request.send(); return; @@ -98,11 +106,5 @@ function parseURLParameters() { viewer = pannellum.viewer('container', configFromURL); } -// Display error if opened from local file -if (false && window.location.protocol == 'file:') { - anError('Due to browser security restrictions, Pannellum can\'t be run ' + - 'from the local filesystem; some sort of web server must be used.'); -} else { - // Initialize viewer - parseURLParameters(); -} +// Initialize viewer +parseURLParameters();