Relationship between windows and forms, relationship between windows and forms
Relationship between windows and forms:Through window. the Window object of the new Window created by open () has the opener attribute. You can open its original Window through opener so that the two windows can be referenced by each other, you can read the attribute methods of each other, and the form is the same. The form is created by <iframe>. The element has the contentWindow attribute, which references its own Window object. The Window object has the frameElement attribute. If the Window object represents a form, frameElement is a reference to the <Iframe> element, for example, for the element <iframe id = 'f1'>, var elt = document. getElementById ('f1'); var win = elt. contentWindow; win. frameElement = elt; // true window. frameElement = elt; // false is always false for top-level windows. Each Window object has a frames attribute, including the form and subform. The frames attribute references the Window objects of the forms and subforms it contains. frames is a class array object composed of these Window objects, which can be indexed by numbers or form names, for example, reference the first child form frames [0] and reference the third child form frames [1] of the second child form. frames [2], referencing the sibling form parent. frames [1]. Built-in objects are independent of each other in different windows and forms. They have their own copy of independent constructors and prototype objects, it is automatically pre-defined in all window forms, while custom objects are different. The constructor and prototype of the object can be shared between windows and forms that can communicate with each other; for example, if the window defines the Set class with sub-Forms A and B, in the parent window: var s = new Set (); String. toString = function () {return 'built-in object';} (modify the toString method of String) s. a = 1; // true in A: var sa = new parent. set (); parent. set. prototype. a = 1; (If attribute a is added to the prototype of the custom class Set, all the windows that can communicate with each other share a) var str = 'test'; str. toString; // test (the toString method of the String object of Form A is called) in B: var Set = top. set (); var sb = new Set (); sb. a = 1; // true to reference a form in the window, you can use the following syntax: frames [I] // framework self of the current window. frames [I] // frame of the current window w. frames [I] // the framework of window w references the parent window (or parent frame) of a Framework. You can use the following syntax: parent // The parent window self of the current window. parent // The parent window w of the current window. the parent window of parent // window w must be referenced from any framework contained in the top-level window. You can use the following syntax: top // top-level window self of the current framework. top // top-level window of the current framework f. top // top-level window of framework f