IFRAME Usage and Precautions _ Experience Exchange
Source: Internet
Author: User
This article mainly describes the use of the IFRAME and considerations:
Many comrades on the IFRAME is how to control, not very understanding, basically still in a vague understanding of the state.
Note for two things, IFR is an ID and NAME value with an IFRAME in existence:
document.getelementbyid ("IFR");
window.frames["IFR"];
To use a function within an IFRAME, a variable must pass the second method. Because it takes a complete DOM model (not sure if that's right). The first method is to simply take out an object.
If only want to change the iframe src or border, scrolling and so on attributes (and property is not a concept, property is not written in the label, such as: scrollheight,innerhtml, etc.), You need to use the first method.
If you want to get the page of an IFRAME (not the IFRAME itself), you need to use the second method, because it takes a complete DOM model, such as the content of the document.body of the IFRAME, which can only be used in the second way.
Also note that a very serious error occurs when invoking the DOM model of the IFRAME when the page of the IFRAME is not fully loaded, so you have to prepare a fault tolerant mode.
Here is an example, one is aa.htm, one is bb.htm, please test to local running, why not I said it!
Aa.htm
<textarea id="runcode13215"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <title>untitled page</title> <st YLE type= "Text/css" > <!--body{margin:0px;}--</style> </pead> <body> </body> </p Tml></textarea>
[Ctrl + A full selection Note: If you need to introduce external JS need to refresh to execute]
Bb.htm
<textarea id="runcode4929"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <title>sub frame</title> <style t Ype= "Text/css" > <!--html,body{margin:0px; width:90%;}--</style> </pead> <body> I ' m A Sub frame! ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... . .. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... . .. .... </body> </ptml></textarea> , ....., ...../--------
[Ctrl + A full selection Note: If you need to introduce external JS need to refresh to execute]
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.