Author: Qiu Source: NEW YORK page Taoba
Throughout the website, the speed is slow, but almost every page will put what Banner, column picture, copyright, etc., of course, for the unity of the website, the need for advertising effect, this is not thick, After all, let the user's wallet "embellished" thing "is increasingly rich", there is no way, let these mini things do not have to download after downloading, and only download the contents of the contents of the region. ?
The answer is very affirmation: apply iframe tag!
First, the use of iframe tag
Lift iframe, maybe you have already thrown it into "Forgotten corners", but, it is not strange to say that his brother Frame will not be strange. Frame tag is a frame mark, what we said is to display multiple HTML files in a browser window. Now, we encounter a very real situation: if there is a tutorial, it is a section of the section, and do a "last section", "the next section" link at the end of each page, except for each tutorial content In addition, the contents of the other parts of the page are the same. If a page is a stupid page, this seems to be too annoying. At this time, if there is a way to keep the page elsewhere, only the tutorial As a page of the content page, does not contain other content, when you click on the top and down link, only change the tutorial content part, others remain unchanged, so that one is saving, the other will be three long two shorts. It is also very convenient, not in the absence of the army; more importantly, it is no longer downloading those advertising banner, column list, navigation and other things. Iframe tag, a floating frame tag, you can use it to embed an HTML document in an HTML. It is different from the maximum feature of the Frame tag, that is, the HTML file referenced by this mark is not independently independent of the other HTML file, but can be embedded in an HTML file, integrated with this HTML file, and becomes a whole, You can also display the same content in a page multiple times without having to write content, and a metaphor of an image is "painting" TV.
Now let's talk about the use of iframe tags.
The usage format of the iframe tag is:
SRC: The path of the file is both an HTML file or a text, ASP, etc.
Width, Height: The width and high in the "Painting" area;
Scrolling: When the specified HTML file specified by the SRC does not complete the specified area, scroll options, if set to NO, no scroll bar is displayed; if it is Auto:, the scroll bar is automatically displayed; if Yes is displayed;
FrameBorder: The width of the area border, in order to make "painting" with the adjacent content, often set to 0.
such as:
1. Access and control the object in the child form in the parent form
In a parent form, iframe is a child object of the Document object, you can access objects in the child form directly in the script.
There is a problem now, that is, how do we control this iframe, here you need to talk about the iframe object. When we set the ID attribute to this mark, you can control the HTML included by the IFRAME through the document object model DOM.
For example, in the example.htm file in the test.htm file and control some tag objects in Test.htm:
Test.htm file code is:
body>
html>
If we want to change the text in the H1 mark of the ID number for myh1 as hello, My Dear, then available:
Document.myh1.innerText = "Hello, My Dear" (where Document is province)
In an Example.htm file, the sub-form referred to by iframe tag object consistent with the general DHTML object model, the same, like the object access control, will not be described again.
2, access and control the object in the parent form in the child form
In sub-forms we can access objects in the parent window through its Parent, parent (diverse) object.
Such as eXample.htm:
body>
html>
If you want to access the title text in Myh2 in Frame1.htm and change it to "Hello, My Friend", we can write:
Parent.myh2.innertext = "Hello, My Friend"
Here, the Parent object represents the current form (the form of Example.htm), and to access objects in the parent form in the child form, there is no exception to pass through the Parent object. Although IFRAME is embedded in another HTML file, it maintains relative independence, is a "independent kingdom" 哟, in a single HTML, the characteristics are equally applicable to floating frames.
Imagine, through the iframe tag, we can express those constant content in iFrame, so that you don't have to copy the same content, this is a bit image or function in the program design, which reduces how much cumbersome manual labor! In addition, it is important that it makes the page's modification more feasible, because you don't have to modify each page because of a layout adjustment, you only need to modify the layout of a parent form.
One thing to note that the Nestscape browser does not support the IFRAME tag, but in the world of IE, this seems to have no more important, widely uses iframe tags, both for themselves, and saving netizens, Why is it not?
Example: