WEB通用弹出子页面且置顶

本文介绍了一个使用纯JavaScript实现的网页弹窗功能。该方法通过修改特定元素的样式属性来显示和定位弹窗,并且能够调整弹窗的位置和大小以适应不同的窗口尺寸。此外,还提供了一个关闭弹窗的功能。

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

 function openpopwin( url, h, w )
 {
     document.getElementById( "popwin" ).style.display = "block";
     document.getElementById( "popwinback" ).style.display = "block";
     document.getElementById("popwinweb").src = url;
     document.getElementById( "popwin" ).style.top = ( document.documentElement.clientHeight - h ) / 2;
     document.getElementById( "popwin" ).style.left = ( document.documentElement.clientWidth - w ) / 2;
     document.getElementById( "popwin" ).style.height = h;
     document.getElementById( "popwin" ).style.width = w;
     document.getElementById("popwinweb").height = h;
     document.getElementById("popwinweb").width = w;
     document.getElementById( "popwinback" ).style.height = document.body.scrollHeight;
     document.getElementById( "popwinback" ).style.width = document.body.scrollWidth;
    

 }
 // 关闭提示画面
 function closepopwin()
 {
     document.getElementById( "popwin" ).style.display = "none";
     document.getElementById( "popwinback" ).style.display = "none";
     document.getElementById("popwinweb").src = "about:blank";
 }

 

 

    <div id="popwin" style="position: absolute; z-index: 100; display: none;">
        <iframe id="popwinweb" name="popwinweb" frameborder="0"></iframe>
    </div>
    <div id="popwinback" style="position: absolute; z-index: 90; display: none; filter: Alpha(opacity=36);
        height: 200%; width: 100%; top: 0; left: 0; overflow: hidden;">
        <iframe name="popwinbackweb" style="height: 200%; width: 200%; top: -10%; left: -10%;"
            onload="aboutblank();"></iframe>
    </div>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值