Frameset, Frame, iframe detailed three: JavaScript operation Frameset__java

Source: Internet
Author: User
Window Properties description
frames[] Store Current window An array of all the frame objects in the The number of
length window frame is equivalent to window.frames.length. The name of the current window for
name , since JavaScript 1.1, this value is read-write. A reference to the parent window for
parent .
self A reference to the window itself.
top a reference to the highest level window, which is usually consistent with parent, unless there are more frame in the frame.
window Another reference to the current window.

 Parent.html:  <! doctype html public  "-//w3c//dtd xhtml 1.0 frameset//en"   "http://www.w3.org /tr/xhtml1/dtd/xhtml1-frameset.dtd ">  

The parent.html document body can be thought of as three frame, frame2, frame5 parent.

1. Obtain the number of frame in the parent window:

Window.frames.length

2. Get the number of frame in the child window:

Window.parent.frames.length//or Parent.frames.length

Parent represents a form's parents form, or it can use top to represent the highest level form, which can be written as top.frames.length, but note that parent and top usually represent an object unless you have nested frame.

3. Access the window in the IFRAME to access a frame, you can query the frames array by name or subscript, Parent.frames[0].name will output the first frame name, in our case frame1 , we can also use parent.frame1 or parent.frames["frame1" to do the same thing, and remember that a frame is a window, and knowing this, you can use all the Windows and Document methods.

When you understand the relationship between frames, you can easily manipulate any frame by parent.frames[, if you have a simple frame page:

Use the following code in any frame to get frame2 var varframe2 = parent.frames[1]; or use the name

4. Control these IFRAME

An IFRAME is a frame variant that needs to be noticed, with an IFRAME that allows you to not use the frame, but can embed the page. In fact, we can also use the Frames[method, and if your IFrame has a name, it can be manipulated by getElementById,   Examples are as follows: <iframe src= "http://www.google.com" name= "iframe1" id= "iframe1" height= "width=" ></iframe> <form action= "" method= "get" > <input type= "button" value= "Load by Frames Array" onclick= "frames[' iframe1 '].loc ation= ' http://www.javascriptref.com '; "/> <input type=" button "value=" Load by DOM "onclick=" document.getElementById (' iframe1 '). src= ' http://www.pint.com ';/> </form>

Point the action to the target frame by adding target to the link label: <a href= "http://www.google.com" target= "FrameName" >Google</a>

5. Access to different elements of multiple forms A. Using index number: Parent.frames[index1].docuement.forms[index2]
B. Use of frame names and ID:parent.framesName.document.getElementById ()

thefather.html

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.