在easyXDM中更新文档URL

时间:2013-02-25 18:16:51

标签: javascript sockets iframe cross-domain easyxdm

如何使用easyXDM动态更新消费者的位置?

我尝试了以下代码但没有成功。

提供商

var socket = new easyXDM.Socket({
  onReady: function(){
    socket.postMessage("update-remote");
  },
  onMessage: function(message, origin) {
   alert("received " + message + " from " + origin);
  }
});

消费

var socket = new easyXDM.Socket({
  remote: "http://remotedomain/page1.html",
  remoteHelper: "http://remotedomain/name.html",
  onReady: function(){
    socket.postMessage("foo-message");
  },
  onMessage: function(message, origin) {
   if(message="update-remote") {
     this.remote = "http://remotedomain/page2.html",
   }
   alert("received " + message + " from " + origin);
  }
});

0 个答案:

没有答案