The iframe frame sets the white background to transparent in IE browser

The iframe frame sets the white background to transparent in IE browser
Recently, I need to frequently use iframe to draw the hierarchical framework of the page in the process of doing the project. Most browsers have no background, but iframe has a white background color by default in IE. When the main background color is not white, it will appear very abrupt in this part. The solution is given in the help manual, which is to set the allowTransparent attribute in the iframe to true. Corresponding examples are also given in the help document, as follows:

Copy code
The code is as follows:

<BODY STYLE="background-color: red">
<IFRAME ID="Frame1" SRC="transparentBody.htm" allowTransparency="true">
</IFRAME>
<IFRAME ID="Frame2" SRC="transparentBody.htm" allowTransparency="true"
STYLE="background-color: green">
</IFRAME>
<IFRAME ID="Frame3" SRC="transparentBody.htm">
</IFRAME>
<IFRAME ID="Frame4" SRC="transparentBody.htm"
STYLE="background-color: green">
</IFRAME>
</BODY>

Theoretically, there is no problem doing this, but IE doesn't seem to respond much and there is still a white background. In fact, at this step, we also need to add <body bgColor="transparent"> to the <body> tag of the subpage, as shown below:
http://img.blog.csdn.net/20140610165850968?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQva3VucGVuZ19tdWJhbw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center

main.html main page code:

Copy code
The code is as follows:

<html>
<head>
<title></title>
</head>
<body style="background-color:blue;">
<table
style="width:100%;border:0;height:100%;cellpadding:0;cellspacing:0">
<tr height="100%">
<td height="100%" width="30%">
<iframe id="test1" src="test1.html" allowTransparency="true" width="100%" height="100%"></iframe></td>
<td height="100%" width="40%">
<iframe id="test2" src="test2.html" allowTransparency="true" width="100%" height="100%"></iframe></td>
<td height="100%" width="30%">
<iframe id="test3" src="test3.html" width="100%" height="100%"></iframe></td>
</tr>
</table>
</body>
</html>

test1.html page code:

Copy code
The code is as follows:

<html>
<head>
<title></title>
</head>
<body bgcolor="transparent">
<h1>test1</h1>
</body>
</html>

test2.html page code:

Copy code
The code is as follows:

<html>
<head>
<title></title>
</head>
<body>
<h1>test2</h1>
</body>
</html>

test3.html page code:

Copy code
The code is as follows:

<html>
<head>
<title></title>
</head>
<body>
<h1>test3</h1>
</body>
</html>

This small example mainly applies the allowTransparency attribute of the iframe tag. When this attribute is set to true and the background color of the <body> tag of the subpage loaded by the iframe is set to transparent, the iframe will become transparent.

allowTransparency sets or gets whether the object can be transparent.
bgColor Sets or gets the background color of the object.

<<:  Detailed explanation of Nginx passively checking the server's survival status

>>:  How to generate mysql primary key id (self-increment, unique and irregular)

Recommend

jQuery implements simple button color change

In HTML and CSS, we want to set the color of a bu...

Detailed explanation of the use of state in React's three major attributes

Table of contents Class Component Functional Comp...

JavaScript data visualization: ECharts map making

Table of contents Overview Precautions 1. Usage 2...

Vue2.0 implements adaptive resolution

This article shares the specific code of Vue2.0 t...

Embedded transplant docker error problem (summary)

After a long period of transplantation and inform...

JavaScript lazy loading detailed explanation

Table of contents Lazy Loading CSS styles: HTML p...

A brief talk on responsive design

1. What is responsive design? Responsive design i...

Basic knowledge of MySQL database

Table of contents 1. Understanding Databases 1.1 ...

Mysql Workbench query mysql database method

Mysql Workbench is an open source database client...

Example code for implementing div concave corner style with css

In normal development, we usually use convex roun...

A brief understanding of the relevant locks in MySQL

This article is mainly to take you to quickly und...

MYSQL database basics - Join operation principle

Join uses the Nested-Loop Join algorithm. There a...