Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GeoGebra deployggb.js IE9 patch regarding XHR's setRequestHeader failing
From 7d56c5f5ae82437144616a75149ea90326c3ebc1 Mon Sep 17 00:00:00 2001
From: Janne Cederberg <janne@opetus.tv>
Date: Fri, 24 Oct 2014 17:44:44 +0300
Subject: [PATCH] Fix deployggb.js for at IE9 when embedding from GeoGebraTube
IE9 (and probably earlier too) don't support setRequestHeader(...)
method on IE's custom XDomainRequest object. Also it will
abort the xhr.send(...) call if XHR's onprogress-handler is not
set to at least a no-op function.
---
deployggb.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/deployggb.js b/deployggb.js
index 291dc3a..fbab62e 100644
--- a/deployggb.js
+++ b/deployggb.js
@@ -563,9 +563,12 @@ var GGBApplet = function() {
// Response handlers.
xhr.onload = success;
xhr.onerror = onError;
+ xhr.onprogress = function(){}; // IE9 will abort the xhr.send without this
// Send request
- xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ if ( xhr.setRequestHeader ) { // IE9's XDomainRequest does not support this method
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ }
xhr.send(JSON.stringify(api_request));
};
@@ -1447,4 +1450,4 @@ var GGBApplet = function() {
}
return applet;
-};
\ No newline at end of file
+};
--
1.7.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment