平日喜欢关注一些新闻,经常会浏览腾讯网!
但是很少看到评论的回复。与是仔细寻找之,发现原来是通过一个页面的弹出遮罩来显示的。
与是仔细研究一翻,自己模拟出来一个,感觉还行,兼容ie 8/chrome/firefox.
思路:主页面和遮罩是两个不同的页面,遮罩通过iframe 利用js加载进来。
代码如下:
index.html
复制代码代码如下:
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="/UploadFiles/2021-03-30/jquery.min.js"><title>append-iframe</title>
<style type="text/css">
html,body{height:100%;padding:0px;margin:0px;}
</style>
</head>
<body>
<div><input type="button" value="show" id="show-id"/></div>
<div><input type="button" value="test" id="test-id"/></div>
<script type="text/javascript">
$("#show-id").on("click",function(){
$(top.document.body).append('<iframe src="/UploadFiles/2021-03-30/subiframe.html">});
$("#test-id").on("click",function(){
alert("test");
});
</script>
</body>
</html>
subiframe.html:
复制代码代码如下:
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="/UploadFiles/2021-03-30/jquery.min.js"><title>Document</title>
<style type="text/css">
html,body{height:100%;padding:0px;margin:0px;}
.np-popframe-bg-opacity{
filter: alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;
}
.wrapper{
position: absolute;
border:1px solid red;
width:800px;
height: 800px;
background: #fff;
top:1000px;
left:500px;
}
</style>
</head>
<body class="iframe-body" style="background-image: none; width: 100%; height: 100%; background-position: initial initial; background-repeat: initial initial;">
<div class="np-popframe-bg-opacity" style="height: 100%; width:100%; background-color:#000;"></div>
<div class="np-popframe-bg" id="np-popframe-bg-id" style="height: 100%; width:100%; position:absolute; top:0px; left:0px;"></div>
<div class="wrapper" id="wrapper-id"></div>
</body>
<script type="text/javascript">
(function(){
$("#wrapper-id").animate({top:"100px"},"slow");
$("#np-popframe-bg-id").on("click",function(){
//$(window.parent.document.getElementById("np-pop-iframe")).remove();
$("#np-pop-iframe",window.parent.document).remove();
});
})(jQuery);
</script>
</html>
这里需要用一到滤镜。让加载来的遮罩保持透明.
1 np-popframe-bg-id 的作用主要是显示评论框的外部区域。当鼠标点击该区域的时候,移除iframe.
2 div 需要设置100%的高度,需要在前面加上 html,body{height:100%;}的css,否则无效
3 还有一点就是绝对定位的absolute.
偶有所得,以记录之,谨防忘记!
但是很少看到评论的回复。与是仔细寻找之,发现原来是通过一个页面的弹出遮罩来显示的。
与是仔细研究一翻,自己模拟出来一个,感觉还行,兼容ie 8/chrome/firefox.
思路:主页面和遮罩是两个不同的页面,遮罩通过iframe 利用js加载进来。
代码如下:
index.html
复制代码代码如下:
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="/UploadFiles/2021-03-30/jquery.min.js"><title>append-iframe</title>
<style type="text/css">
html,body{height:100%;padding:0px;margin:0px;}
</style>
</head>
<body>
<div><input type="button" value="show" id="show-id"/></div>
<div><input type="button" value="test" id="test-id"/></div>
<script type="text/javascript">
$("#show-id").on("click",function(){
$(top.document.body).append('<iframe src="/UploadFiles/2021-03-30/subiframe.html">});
$("#test-id").on("click",function(){
alert("test");
});
</script>
</body>
</html>
subiframe.html:
复制代码代码如下:
<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="/UploadFiles/2021-03-30/jquery.min.js"><title>Document</title>
<style type="text/css">
html,body{height:100%;padding:0px;margin:0px;}
.np-popframe-bg-opacity{
filter: alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;
}
.wrapper{
position: absolute;
border:1px solid red;
width:800px;
height: 800px;
background: #fff;
top:1000px;
left:500px;
}
</style>
</head>
<body class="iframe-body" style="background-image: none; width: 100%; height: 100%; background-position: initial initial; background-repeat: initial initial;">
<div class="np-popframe-bg-opacity" style="height: 100%; width:100%; background-color:#000;"></div>
<div class="np-popframe-bg" id="np-popframe-bg-id" style="height: 100%; width:100%; position:absolute; top:0px; left:0px;"></div>
<div class="wrapper" id="wrapper-id"></div>
</body>
<script type="text/javascript">
(function(){
$("#wrapper-id").animate({top:"100px"},"slow");
$("#np-popframe-bg-id").on("click",function(){
//$(window.parent.document.getElementById("np-pop-iframe")).remove();
$("#np-pop-iframe",window.parent.document).remove();
});
})(jQuery);
</script>
</html>
这里需要用一到滤镜。让加载来的遮罩保持透明.
1 np-popframe-bg-id 的作用主要是显示评论框的外部区域。当鼠标点击该区域的时候,移除iframe.
2 div 需要设置100%的高度,需要在前面加上 html,body{height:100%;}的css,否则无效
3 还有一点就是绝对定位的absolute.
偶有所得,以记录之,谨防忘记!
标签:
评论回复,弹出,遮罩
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“评论回复弹出遮罩效果实现思路兼容ie 8/chrome/firefox”评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新动态
2024年05月07日
2024年05月07日
- 田震《永远执着 田震20周年纪念精选 2CD》[WAV+CUE][1.3GB]
- 【民族融合】VA-2024-TheOrientCollective:SpaceTribe(FLAC)
- 林友仁-《雪夜闻钟》(2013)[FLAC+CUE]
- KOKIA-Wheretogomylove_(2013Remaster2014)[24bit96kHzFLAC]
- ABC唱片-《监听耳机天碟》6N纯银镀膜[WAV+CUE]
- ABC唱片-《正毒.超强人声测试发烧碟片》6N纯银镀膜[WAV+CUE]
- ABC唱片-《彭修文.一代巨人》6N纯银镀膜[WAV+CUE]
- ABC唱片-《木村好夫.860万吉他》6N纯银镀膜[WAV+CUE]
- ABC唱片-《马克柯贝.我至爱你大提琴》6N纯银镀膜[WAV+CUE]
- 云水谣《小调江南2·西湖情思》APE+CUE
- 蔡琴《精选-梦中人 人声试音典范 4CD》[WAV+CUE][1.9GB]
- 群星《妙音纪念珍藏版贰》[WAV+CUE][650MB]
- 群星《宝丽金摘金宝典 3CD》[WAV+CUE][1.9GB]
- 中唱《好歌珍藏--明月寄情》500首经典优美旋律30CD[WAV]
- 【古典音乐】卡拉扬《首次录音(6)》2006[FLAC+CUE整轨