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>-->
The following cannot be displayed normally:
<body> <frameset rows="50%,*"> <frame name="frame1" src="test1.htm"/> <frame name="frame2" src="test2.htm"/> </frameset> <body>
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>
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>
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>
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!