Script operation framework page

Source: Internet
Author: User

Test environment: IE6, ie9, Firefox
Jquery reference address:
<SCRIPT type = "text/JavaScript" src = "http://code.jquery.com/jquery-latest.js"> </SCRIPT>
1. IFRAME framework
Page example:
<IFRAME id = "ifr1" frameborder = "1" scrolling = "no" src = "H16-1.htm" style = "width: 45%; Height: 250px"> </iframe>
<IFRAME id = "ifr2" frameborder = "1" scrolling = "no" src = "H16-2.htm" style = "width: 45%; Height: 250px"> </iframe>
The parent page contains two child frameworks: ifr1 ifr2
1) parent page calls child pages
A. The parent page obtains the text box in the ifr1 framework and writes the content
VaR OBJ = Document. getelementbyid ("ifr1"). contentWindow;
// Jquery Method
// $ ("# Txt1", obj.doc ument). Val ("parent page write child page" + math. Floor (math. Random () * 1000 ));
// JavaScript Method
Obj.doc ument. getelementbyid ("txt1"). value = "11 parent page write child page" + math. Floor (math. Random () * 1000 );
B. Call functions on the Framework page on the parent page (addmsg is a function in the ifr1 Framework)
VaR OBJ = Document. getelementbyid ("ifr1"). contentWindow;
OBJ. addmsg ("parent page calls subpage function write information" + math. Floor (math. Random () * 1000 ));
C. Rewrite the child frame link on the parent page
// Rewrite the sub-framework Link
// Jquery Method
// $ ("# Ifr1"). ATTR ("src", $ ("# ifr1"). ATTR ("src "));
// JavaScript Method
Please wait Doc ument. getelementbyid ("ifr1"). src = Please wait Doc ument. getelementbyid ("ifr1"). SRC;
D. Use the [] method to obtain the framework object
// Use the [] method to obtain the framework object
// Jquery Method
// $ (Window. Frames ["ifr1" cmd.doc ument). Find ("input [type = 'Radio ']"). ATTR ("checked", "true ");
// JavaScript Method
Window. Frames ["ifr1" 2.16.doc ument. getelementbyid ("txt1"). value = "11 this is the content written to the parent page ";
2) frame Page Operation parent page
A. Get the parent page element and assign values
// Obtain the parent page element and write data
// Jquery Method
// $ ("# MSG", parent.20.20.document).html ("Get the parent page element and write data !!! "+ Math. Random ());
// JavaScript Method
Parent.w.w.domaindoc ument. getelementbyid ("MSG"). innerhtml = "11. Get the parent page element and write data !!! "+ Math. Random ();
B. Call the parent page Function
// Call the parent page function addmsg --- parent page Function
Parent. Window. addmsg ("11 call the parent page function and write content" + math. Random ());
3) sibling framework interoperability
A. Obtain and assign values to the sibling framework elements.
// Obtain the sibling framework element and write data to ifr2 to obtain the element in ifr1
// Jquery Method
// $ ("# Ifr1", parent.doc ument ). CONTENTS (). find ("# txt2 "). val ("this is written by the Framework ifr2" + math. random ());
// JavaScript Method
Parent.doc ument. getelementbyid ("ifr1" 2.16.content1_doc ument. getelementbyid ("txt2"). value = "11 this is what the framework writes to ifr2" + math. Random ();
B. Call brother FRAMEWORK Functions
// Call the sibling framework function ifr2 to call the function in ifr1
// Jquery Method
// $ ("# Ifr1", parent.doc ument) [0]. contentWindow. addmsg ("this is also written by function 1 of framework 2 call" + math. Random ());
// JavaScript Method
Parent.doc ument. getelementbyid ("ifr1"). contentWindow. addmsg ("11 this is also written by the function of framework 2 calling framework 1" + math. Random ());
2. frameset framework
Page example
<Frameset id = "framesx" border = "1" framespacing = "5" rows = "165, *" frameborder = "1" runat = "server" width = "100%">
<Frame id = "ifr1" name = "ifr1" framespacing = "5" marginwidth = "0" marginheight = "0" src = "h16a-1.htm" noresize scrolling = "no" target = "">
<Frameset id = "mainframe" border = "1" framespacing = "5" frameborder = "1" Cols = "50%, 50%" runat = "server">
<Frame id = "ifr2" name = "ifr2" marginwidth = "20%" marginheight = "100px" src = "h16a-2.htm" noresize scrolling = "no">
<Frame width = "100%" id = "ifr3" name = "ifr3" marginwidth = "0" marginheight = "0" src = "h16a-3.htm" noresize scrolling = "Auto">
</Frameset>
</Frameset>
The page is divided into: Top -- left: Right. The top is iffr1, the left is ifr2, And the right is ifr2.
The name attribute must be used during the Firefox test. We recommend that you set the ID and name to the same name.
1) obtain other framework elements and assign values
In this example, the left-side page (ifr2) is operated through the top page (ifr1)
// Jquery Method
// $ ("# Div", window. Parent. Frames ["ifr2" 2.16.document).html ("Get brother framework and write data !!! "+ Math. Random ());
// JavaScript Method
Window. Parent. Frames ["ifr2" 2.16.doc ument. getelementbyid ("Div"). innerhtml = "1 get the sibling framework and write data !!! "+ Math. Random ();
2) call other framework page Functions
// Jquery
// $ (Window. Parent. Frames ["ifr2"]) [0]. Add ("call brother framework function ");
// JavaScript Method
Window. Parent. Frames ["ifr2"]. Add ("call brother framework function 11 ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.