The iframe child page operates the parent page and implements the effect of shielding the page pop-up layer

The iframe child page operates the parent page and implements the effect of shielding the page pop-up layer
Question: In index.html, iframe introduces son.html. How can I click on a certain operation in son.html to block the entire page and pop up the layer to be displayed?
Prepare: index.html son.html
Ideas:
1: Introduce son.html into iframe in index.html,

Copy code
The code is as follows:

<!-- Right iframe starts-->
<div id="resDiv" class="resDiv">
<iframe name="res" class="iframestyle" allowtransparency="true" src="son.html" frameborder="0" scrolling="no"></iframe>
</div>
<!-- End of right iframe -->

2: Add a shielding layer and a content display layer to the body of index.html

Copy code
The code is as follows:

<!--Pop-up login page layer-->
<div id="mapLayer" style="display: none; " >
<input type="button" value="Close" onclick="closeMap()" />
</div>
<!--Shielding layer, used to transparently shield the entire page-->
<div id="mapBgLayer" style="position:absolute; display: none;"></div>

3: How to set the div style and open and close the layer in index.html

Copy code
The code is as follows:

<style type="text/css">
#BgLayer {
background: #939393 none repeat scroll 0 0;
height:100%;
width:100%;
left:0;
top:0;
filter: alpha(opacity=80); /* IE */
-moz-opacity: 0.8; /* Moz + FF */
z-index: 10000;
}
#Layer {
width: 400px;
height: 400px;
margin: -180px 0 0 -170px;
left: 50%;
top: 50%;
position: absolute;
background: #FFF;
z-index: 10001;
border: 1px solid #1B5BAC;
}
</style>
<script type="text/javascript">
/*Display page*/
function showDiv) {
var bg = document.getElementById("BgLayer");
var con = document.getElementById("Layer");
//var w = document.documentElement.clientWidth; //Width of visible area of ​​web page
//var h = document.documentElement.clientHeight; //Height of visible area of ​​web page
var w = document.body.scrollWidth; //Full text width of the webpage
var h = document.body.scrollHeight; //Height of the full text of the web page
// alert(w+"-"+h);
bg.style.display = "";
bg.style.width = w + "px";
bg.style.height = h + "px";
con.style.display = "";
}
/*closure*/
function closeDiv() {
var bg = document.getElementById("BgLayer");
var con = document.getElementById("Layer");
bg.style.display = "none";
con.style.display = "none";
}
</script>

4: An operation in son.html calls a method on the parent page

Copy code
The code is as follows:

<a href="javascript:void(0)" onclick="parent.window.showDiv()">View</a>

<<:  Creative opening effect achieved by combining CSS 3.0 with video

>>:  MySQL 8.0.26 installation and simplified tutorial (the most complete on the Internet)

Recommend

MySQL storage engine basics

In the previous article, we talked about MySQL tr...

How to configure two-way certificate verification on nginx proxy server

Generate a certificate chain Use the script to ge...

Detailed explanation of Vue's sync modifier

Table of contents 1. Instructions 2. Modifiers 3....

Complete steps to install Anaconda3 in Ubuntu environment

Table of contents Introduction to Anaconda 1. Dow...

Detailed explanation of prototypes and prototype chains in JavaScript

Table of contents Prototype chain diagram Essenti...

Simple example of HTML text formatting (detailed explanation)

1. Text formatting: This example demonstrates how...

Detailed explanation of MySQL 8.0 password expiration policy

Starting from MySQL 8.0.16, you can set a passwor...

The combination and difference between ENTRYPOINT and CMD in dockerfile

In the previous article [Detailed explanation of ...

4 ways to modify MySQL root password (summary)

Method 1: Use the SET PASSWORD command First log ...

In-depth explanation of JavaScript this keyword

Table of contents 1. Introduction 2. Understand t...

Detailed explanation of computed properties in Vue

Table of contents Interpolation Expressions metho...

How to deploy MySQL and Redis services using Docker

Table of contents How to deploy MySQL service usi...

How to use the debouce anti-shake function in Vue

Table of contents 1. Anti-shake function 2. Use d...