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

JavaScript to achieve the effect of tab bar switching

Tab bar: Click different tabs to display differen...

How to monitor Linux server status

We deal with Linux servers every day, especially ...

Vue3+TypeScript encapsulates axios and implements request calls

No way, no way, it turns out that there are peopl...

How to use negative margin technology to achieve average layout in CSS

We usually use float layout to solve the compatib...

Linux file management command example analysis [display, view, statistics, etc.]

This article describes the Linux file management ...

MySQL 5.7.17 installation and configuration graphic tutorial

Features of MySQL: MySQL is a relational database...

How to install Element UI and use vector graphics in vue3.0

Here we only focus on the installation and use of...

A method of hiding processes under Linux and the pitfalls encountered

Preface 1. The tools used in this article can be ...

HTML uses marquee to achieve text scrolling left and right

Copy code The code is as follows: <BODY> //...

Example sharing of anchor tag usage in HTML

Anchor tag usage: Linking to a specific location i...

Implementation of socket options in Linux network programming

Socket option function Function: Methods used to ...

Tutorial on installing MySQL 5.6 on CentOS 6.5

1. Download the RPM package corresponding to Linu...