Skip to content
Browse files

imported iexdomain

  • Loading branch information...
1 parent 8c8db83 commit 98cee612bcf1c6a166fa1c2903d7cb6f8f26d4d8 @flosse flosse committed Jan 28, 2012
Showing with 39 additions and 0 deletions.
  1. +3 −0 README.markdown
  2. +36 −0 iexdomain/iexdomain.js
View
3 README.markdown
@@ -71,6 +71,9 @@ https://github.com/metajack/strophejs-plugins .
- [Serverdate](strophejs-plugins/tree/master/serverdate/) - Syncs a local clock
to the servers
+- [iexdomain](strophejs-plugins/tree/master/iexdomain/) - Support for IE
+ XDomainRequest
+
## Contribute
If you would like to make your plugin available here, simply fork this
View
36 iexdomain/iexdomain.js
@@ -0,0 +1,36 @@
+Strophe.addConnectionPlugin('iexdomain', {
+ init: function(conn) {
+ // replace Strophe.Request._newXHR with new IE CrossDomain version
+ if (window.XDomainRequest) {
+ Strophe.Request.prototype._newXHR = function() {
+ var xhr = new XDomainRequest();
+ xhr.readyState = 0;
+
+ xhr.onreadystatechange = this.func.prependArg(this);
+ xhr.onerror = function() {
+ xhr.readyState = 4;
+ xhr.status = 500;
+ xhr.onreadystatechange(xhr.responseText);
+ };
+ xhr.ontimeout = function() {
+ xhr.readyState = 4;
+ xhr.status = 0;
+ xhr.onreadystatechange(xhr.responseText);
+ };
+ xhr.onload = function() {
+ xhr.readyState = 4;
+ xhr.status = 200;
+ var _response = xhr.responseText;
+ var _xml = new ActiveXObject('Microsoft.XMLDOM');
+ _xml.async = 'false';
+ _xml.loadXML(_response);
+ xhr.responseXML = _xml;
+ xhr.onreadystatechange(_response);
+ };
+ return xhr;
+ };
+ } else {
+ console.info("Browser doesnt support XDomainRequest." + " Falling back to native XHR implementation.");
+ }
+ }
+});

0 comments on commit 98cee61

Please sign in to comment.
Something went wrong with that request. Please try again.