|
var jsonObj = {};
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
jsonObj.wrappedJSObject = jsonObj;
observerService.notifyObservers(jsonObj, "JsonObjNotify", "");
接收时:
observerService.addObserver(observer, "JsonObjNotify", false);
observe: function(subject, topic, data) {
var jsonReceived = subject.wrappedJSObject;
}
即可。详情请见:https://developer.mozilla.org/en-US/docs/wrappedJSObject
|
|