点击按钮弹出 蒙板 操作页面

本文提供了一个HTML、CSS和JavaScript实现的弹出窗口展示示例,包括窗口大小调整、透明度设置及显示隐藏功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        #divMenBan
        {
            display: none;
            position: absolute;
            z-index: 1000;
            height: 100%;
            width: 100%;
            left: 0px;
            top: 0px;
            background: #000000;
            filter: Alpha(opacity=30);
        }
        #divDisplay
        {
            display: none;
            position: absolute;
            height: 100%;
            width: 100%;
            padding-top: 10%;
            z-index: 1001;
            left: 0px;
            top: 0px;
        }
    </style>
    <script type="text/javascript">
        function ShowDisplay() {

            var winWH = getPageSize();
            //alert(winWH[0] + "  " + winWH[1] + "  " + winWH[2] + "  " + winWH[3] + "  ");
            document.getElementById('divMenBan').style.width = winWH.x.toString() + "px";
            document.getElementById('divMenBan').style.height = winWH.y.toString() + "px";
            document.getElementById('divDisplay').style.width = winWH.x.toString() + "px";
            document.getElementById('divDisplay').style.height = winWH.y.toString() + "px";
            if (document.getElementById('divDisplay').style.display == 'none' || document.getElementById('divDisplay').style.display == '') {
                document.getElementById('divMenBan').style.display = 'block';
                document.getElementById('divDisplay').style.display = 'block';
            }


        }
        function getPageSize() {

            var xScroll, yScroll;

            if (window.innerHeight && window.scrollMaxY) {
                xScroll = document.body.scrollWidth;
                yScroll = window.innerHeight + window.scrollMaxY;
            } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
            } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
            }

            var windowWidth, windowHeight;
            if (self.innerHeight) { // all except Explorer
                windowWidth = self.innerWidth;
                windowHeight = self.innerHeight;
            } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
            } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }

            // for small pages with total height less then height of the viewport
            if (yScroll < windowHeight) {
                pageHeight = windowHeight;
            } else {
                pageHeight = yScroll;
            }

            // for small pages with total width less then width of the viewport
            if (xScroll < windowWidth) {
                pageWidth = windowWidth;
            } else {
                pageWidth = xScroll;
            }


            //arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
            return { x: pageWidth, y: pageHeight };
        }
        var resizeTime = null;
        window.onresize = function () {
            if (resizeTime == null) {
                resizeTime=setTimeout(doResize, 100);
            }
        }
        function doResize() {
            var winWH = getPageSize();
            document.getElementById('divMenBan').style.width = winWH.x.toString() + "px";
            document.getElementById('divMenBan').style.height = winWH.y.toString() + "px";
            document.getElementById('divDisplay').style.width = winWH.x.toString() + "px";
            document.getElementById('divDisplay').style.height = winWH.y.toString() + "px";
        }
    </script>
</head>
<body>
    <div>
        <input type="button" value="弹出" onclick='ShowDisplay();' />
    </div>
    <div id='divMenBan'>
    </div>
    <div id='divDisplay'>
        ksksjksjfksdjfdkasfjasdkfasd
        <br />
        dsafadskfjsalkfj
        <br />
        dsafadskfjsalkfj
        <br />
        dsafadskfjsalkfj
        <br />
        dsafadskfjsalkfj
        <br />
        dsafadskfjsalkfj
        <br />
        dsafadskfjsalkfj
    </div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

感谢一路走过的人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值