Skip to content

Commit

Permalink
fixed: added protocol to this.host
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Aug 14, 2010
1 parent f167407 commit f6c9858
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions static/js/arc_client.js
Expand Up @@ -19,23 +19,24 @@

//send a message to the server on every iFrame load
this.iFrame.onload = function(){
//store the host of the iframe so we aren't posting messages to the wrong site.
self.host = this.ownerDocument.location.host;
//store the host of the iframe so we aren't posting messages to the wrong site.
self.host = this.ownerDocument.location.protocol + "//" + this.ownerDocument.location.host;
self.sendMessage('discover');
};
return this;
};
//: sendMessage
// @options #optional
ArcClient.prototype.sendMessage = function(call, callback, params){
console.log("call:"+call+" host:"+this.host);
if(callback){
var id = Math.floor(Math.random()*100000+(new Date().getTime()));
window.addEventListener('message', function(e){
e.data.id === id && callback.call(this,e);
}, false);
}
var data = {'call': call,'id':id};
if(params) data.params = params;
if(params) data.params = params;
this.iFrame.contentWindow.postMessage(JSON.stringify(data), this.host);
};
window.ArcClient = ArcClient;
Expand Down

0 comments on commit f6c9858

Please sign in to comment.