Skip to content Skip to sidebar Skip to footer

Pass Variable Values From Child Xul Window To Parent Xul Window Using Javascript

I have a function to get the values of the selected check-box from the xul file(Lets say tree.xul). In another XUL file has the text-box where I want to pass the values(label value

Solution 1:

You may want to use something like this: Passing extra parameters to the dialog in XUL

This provides a simple way to pass values across xul files.

For your problem you can do something like this in the textbox.xul. This will open tree.xul along with the extra parameter returnValues:

var returnValues = { out: null };
window.openDialog("tree.xul", "tree", "modal", returnValues);

Note modal is a must.

Next in your tree.xul, store all the values (lets call it x) that you want to pass to textbox.xul as below:

window.arguments[0].out = x

Note window.argument[0] refers to returnValues

Now you can access the values of x (which is the names of the labels in your case) in textbox.xul as follows:

var labels = returnValues.out;

Basically,

  1. You pass a parameter to the child window at the time of opening it.

  2. Then in the child window, fill the parameter with the values that wish to pass back to the parent window and then close the child window.

  3. Now back in the parent window you can access the parameter that you passed to the child and it contains information updated by the child window.

Post a Comment for "Pass Variable Values From Child Xul Window To Parent Xul Window Using Javascript"