You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/03/14 22:29:25 UTC

spec commit: [ALL] catch exception trying to xhr to local file to see if it exists

Updated Branches:
  refs/heads/master d2834bb7c -> 6edfe546c


[ALL] catch exception trying to xhr to local file to see if it exists


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/6edfe546
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/6edfe546
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/6edfe546

Branch: refs/heads/master
Commit: 6edfe546cbff68eb6636ec649b405d2ddd513d54
Parents: d2834bb
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Mar 14 14:28:25 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Mar 14 14:28:25 2013 -0700

----------------------------------------------------------------------
 cordova.js |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/6edfe546/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index 5c3922f..9877d10 100644
--- a/cordova.js
+++ b/cordova.js
@@ -29,14 +29,18 @@ var versionCordovaPath = currentPath.replace("cordova.js", "cordova-" + VERSION
 var cordovaPath = versionCordovaPath;
 
 (function() {
-    var xhr = new XMLHttpRequest();
-    xhr.open("GET", platformCordovaPath, false);
-    xhr.onreadystatechange = function() {
-        if (this.readyState == this.DONE && this.responseText.length > 0) {
-            cordovaPath = platformCordovaPath;
-        }
-    };
-    xhr.send(null);
+    // XHR to local file is an error on some platforms, windowsphone for one 
+    try {
+        var xhr = new XMLHttpRequest();
+        xhr.open("GET", platformCordovaPath, false);
+        xhr.onreadystatechange = function() {
+            if (this.readyState == this.DONE && this.responseText.length > 0) {
+                cordovaPath = platformCordovaPath;
+            }
+        };
+        xhr.send(null);
+    }
+    catch(e){} // access denied!
 })();
 
 if (!window._doNotWriteCordovaScript) {