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

4 Ways to Quickly Teach Yourself Linux Commands

If you want to become a Linux master, then master...

VMware installation of Ubuntu 20.04 operating system tutorial diagram

Memo: Just experience it. Record: NO.209 This exa...

Solution to 1045 error when navicat connects to mysql

When connecting to the local database, navicat fo...

About front-end JavaScript ES6 details

Table of contents 1. Introduction 1.1 Babel Trans...

How to correctly create MySQL indexes

Indexing is similar to building bibliographic ind...

The scroll bar position is retained when scrolling the vant list component

The scroll bar position is retained when scrollin...

Form submission page refresh does not jump

1. Design source code Copy code The code is as fol...

Vue defines private filters and basic usage

The methods and concepts of private filters and g...

Working principle and implementation method of Vue instruction

Introduction to Vue The current era of big front-...

Nginx cache files and dynamic files automatic balancing configuration script

nginx Nginx (engine x) is a high-performance HTTP...

A brief introduction to the usage of decimal type in MySQL

The floating-point types supported in MySQL are F...

Some conclusions on developing mobile websites

The mobile version of the website should at least...

Nodejs error handling process record

This article takes the connection error ECONNREFU...

Solution for Vue routing this.route.push jump page not refreshing

Vue routing this.route.push jump page does not re...