Give an example to explain the difference between iframe and frame in HTML

高洛峰
Release: 2017-02-18 15:54:34
Original
1323 people have browsed it

I don’t know if you have used the frameset attribute in your project. The frameset attribute was used by me in the production of an online customer service system last year, because the customer service system needs a fixed layout, one above, one below, etc. At that time Just use frameset and frame. After I used these attributes, I understood the difference between iframe and frame. Because before this, I generally didn’t use frames in my projects, and if I did, I would use iframes.

Let’s talk about the specific differences! The following points are summarized.

1. Frame cannot be used alone without frameSet, iframe can;

2. Frame cannot be placed in body;

The following can be displayed normally:

<!--<body>-->    
<frameset rows="50%,*">    
   <frame   name="frame1"   src="test1.htm"/>     
   <frame   name="frame2"   src="test2.htm"/>     
</frameset>    
<!--<body>-->
Copy after login

The following cannot be displayed normally:

<body>    
<frameset rows="50%,*">    
   <frame   name="frame1"   src="test1.htm"/>     
   <frame   name="frame2"   src="test2.htm"/>     
</frameset>    
<body>
Copy after login

On the contrary, if the iframe is placed under the frameSet attribute, it must be placed In body

<body>    
  <frameset>     
    <iframe   name="frame1"   src="test1.htm"/>     
    <iframe   name="frame2"   src="test2.htm"/>     
  </frameset>     
</body>
Copy after login

3. iframe is an html tag, which can be used anywhere in html, but frame cannot.

<body>    
   <iframe   name="frame1"   src="test1.htm"/>     
   <iframe   name="frame2"   src="test2.htm"/>     
</body>  
  
<table>    
<tr>    
<td><iframe id="" src=""></iframe></td><td></td>    
</tr>    
</table>
Copy after login

The frame must be nested in the frameSet and cannot be used in tags such as table.

4. The height of the frame can only be controlled through frameSet; iframe can be controlled by itself, but cannot be controlled through frameSet

<!--<body>-->    
<frameset rows="50%,*">    
   <frame   name="frame1"   src="test1.htm"/>     
   <frame   name="frame2"   src="test2.htm"/>     
</frameset>    
<!--</body>-->    
  
<body>    
<frameset>    
   <iframe height="30%"  name="frame1"   src="test1.htm"/>     
   <iframe height="100"  name="frame2"   src="test2.htm"/>     
</frameset>    
</body>
Copy after login

5. If more than two iframes are used on the same page, it can be displayed normally in IE, but only the first one can be displayed in Firefox; if more than two iframes are used, it can be displayed normally in both IE and Firefox

For more examples to explain the difference between iframe and frame in HTML, please pay attention to the PHP Chinese website for related articles!



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template