Using a mask layer in Web pages can prevent repeated operations and prompt loading; it can also simulate pop-up modal windows.
XML/HTML CodeCopy content to clipboard
-
>
-
<html lang="zh-CN">
-
<head>
-
<meta charset="utf-8">
-
<meta http-equiv="X-UA-Commpatible" content="IE=edge">
-
<title>HTML遮罩层title>
-
<link rel="stylesheet" href="css/index.css">
-
head>
-
<body>
-
<div class="header" id="header">
-
<div class="title-outer">
-
<span class="title">
-
HTML遮罩层使用
-
span>
-
div>
-
div>
-
<div class="body" id="body">
-
<iframe id="iframeRight" name="iframeRight" width="100%" height="100%"
- scrolling="no" frameborder="0"
- style="border: 0px;margin: 0px; padding: 0px; width: 100%; height: 100%;overflow: hidden;"
- onload="rightIFrameLoad(this)" src="body.html">iframe>
-
div>
-
-
-
<div id="overlay" class="overlay">div>
-
-
<div id="loadingTip" class="loading-tip">
-
<img src="images/loading.gif" />
-
div>
-
-
-
<div class="modal" id="modalDiv">div>
-
-
<script type='text/javascript' src="js/jquery-1.10.2.js">script>
-
<script type="text/javascript" src="js/index.js">script>
-
body>
-
html>
XML/HTML CodeCopy content to clipboard
-
>
-
<html lang="zh-CN">
-
<head>
-
<meta charset="utf-8">
-
<meta http-equiv="X-UA-Commpatible" content="IE=edge">
-
<title>body 页面title>
-
<style type="text/css">
-
* {
-
margin: 0;
-
padding: 0;
-
}
-
-
html, body {
-
width: 100%;
-
height: 100%;
-
}
-
-
.outer {
-
width: 200px;
-
height: 120px;
-
position: relative;
-
top: 50%;
-
left: 50%;
-
}
-
-
.inner {
-
width: 200px;
-
height: 120px;
-
position: relative;
-
top: -50%;
-
left: -50%;
-
}
-
-
.button {
-
width: 200px;
-
height: 40px;
-
position: relative;
-
}
-
-
.button#btnShowLoading {
-
top: 0;
-
}
-
-
.button#btnShowModal {
-
top: 30%;
-
}
-
-
style>
-
<script type="text/ javascript">
-
-
function showOverlay() {
-
// Call the parent window to display the mask layer and Loading prompts
-
window.top.window.showLoading();
-
-
// Use a timer to simulate closing the Loading prompt
-
setTimeout(function() {
-
window.top.window.hideLoading();
-
}, 3000);
-
-
}
-
-
function showModal() {
-
// Call the parent window method to simulate a pop-up modal window
-
window.top.showModal($('#modalContent').html());
-
}
-
-
script>
-
head>
-
<body>
-
<div class='outer' >
-
<div class='inner' >
-
<button id='btnShowLoading' class='button' onclick='showOverlay();'>Click to pop up the mask layerbutton>
-
<button id='btnShowModal' class='button' onclick='showModal();'>Click to pop up the modal windowbutton>
-
div>
-
div>
-
-
-
<div id='modalContent' style='display: none;'>
-
<div class='modal- container' style='width: 100%;height: 100%;background-color: white;'>
-
<div style='width: 100%;height: 49px;position: relative;left: 50%;top: 50%;'>
-
<span style='font-size: 36px; width: 100%; text-align:center; display: inline-block; position:inherit; left: -50%;top: -50%;'>模态窗口1span>
-
div>
-
<button class='btn-close' style='width: 100px; height: 30px; position: absolute; right: 30px; bottom: 20px;'>关闭button>
-
div>
-
div>
-
<script type='text/javascript' src="js/jquery-1.10.2.js">script>
-
body>
-
html>
-