好的,我有2个xul窗口,
window_2
<label id="#label_id" value="button has been clicked!">
window_1
[button]---> clicked--> $("#label_id).attr("value","clicked again!");
我想在xul的window_1上按下按钮时更改window_2的样式(标签文本),我正在使用jquery,这似乎不起作用,我怎么能绕过这个?
答案 0 :(得分:1)
您需要的是获取另一个窗口的窗口对象。我可以想到几个快速的方法:
创建一个模块并用它来共享每个窗口的窗口对象:
MyWindowModule.jsm
const EXPORTED_SYMBOLS = ["MyWindowModule"];
var MyWindowModule = {
window1: null,
window2: null
}
window1.js
Components.utils.import("resource://myextension/modules/MyWindowModule.jsm");
MyWindowModule.window1 = window;
window2.js
Components.utils.import("resource://myextension/modules/MyWindowModule.jsm");
MyWindowModule.window2 = window;
然后你可以在window1中使用:
MyWindowModule.window2.$("#label_id).attr("value","clicked again!");