js+css jQuery实现页面后退执行 & 遮罩弹框
2024-10-18 21:24:47
JS部分
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script> <script type="text/javascript"> jQuery(document).ready(function ($) {
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
var hashLocation = location.hash;
var hashSplit = hashLocation.split("#!/");
var hashName = hashSplit[1];
if (hashName !== '') {
var hash = window.location.hash;
if (hash === '') {
//alert("希望该网站能提供你帮助!");
$('.onunload-box').css('display', 'inline');
$('.zhezhao').css('display', 'inline');
}
}
});
window.history.pushState('forward', null, './#forward');
}
}); $('.colsebtn').click(function(){
$('.onunload-box').css('display', 'none');
$('.zhezhao').css('display', 'none');
})
//点击遮罩部分,关闭弹框
$('.zhezhao').click(function(){
$('.onunload-box').css('display', 'none');
$('.zhezhao').css('display', 'none');
}) $('.bottom-box').click(function(){
$('.onunload-box').css('display', 'inline');
$('.zhezhao').css('display', 'inline');
}); </script>
CSS部分
.onunload-box{
width:400px;
height:268px;
border:1px #ad1d1d solid;
border-radius: 20px;
text-align: center;
position: fixed;
top:50%;
margin-top:-134px;
left:50%;
margin-left:-200px;
z-index:;
background-color: #fff;
padding:12px 24px 0;
color:#732205;
}
.btns{
height:100px;
width:100%;
border-top:1px #ad1d1d solid;
position: absolute;
bottom:-50px;
left:;
}
.colsebtn{
width:150px;
float:left;
line-height: 50px;
cursor:pointer;
}
.wxgghbtn{
width:256px;
height:50%;
line-height: 50px;
position:absolute;
right:;
background-color:#ad1d1d;
color:#fff;
border-bottom-right-radius: 20px;
}
.wxgghbtn>a{text-decoration: none;color:#fff;}
.p1{font-size:16px;margin-top:}
.p2{font-size:14px;color:#333;margin:0px;}
.p4{font-size:32px;font-weight: bold;margin:0px;}
.zhezhao
{
width:100%;
height:100%;
background-color:#000;
filter:alpha(opacity=60);
-moz-opacity:0.6;
opacity:0.6;
position:fixed;
left:0px;
top:0px;
display:none;
z-index:;
}
HTML部分
<div class='zhezhao'></div>
<div class='onunload-box' style='display:none'>
<p class='p1'>和田玉怎么鉴定的?你知道的和田玉是什么样的</p>
<p class='p2'>据统计,大部分的人都不知道和田玉石如何鉴定的。<br/><br/>鼎石专家教你如何鉴定和田玉小妙招</p>
<p class='p3'>添加鼎石和田玉为公众号好友,专家教您鉴赏和田玉</p>
<p class='p4'><script>document.write(stxlwx);</script></p>
<p class='p5'>先长按上方公众号直接复制</p>
<div class='btns'>
<div class='colsebtn'>谢谢,我不需要</div>
<div class='wxgghbtn' data-clipboard-target='.p4'>关注微信公众号,以后用得着</div>
</div>
</div>
最新文章
- 25个实用的jQuery技巧和解决方案
- Test Design Guidelines for Reusability
- LigerUi框架+jquery+ajax无刷新留言板系统的实现
- JAVA同步容器和并发容器
- PetaPoco 使用总结(一)
- jQuery数据类型总结
- POJ-1155 TELE (树形DP+分组背包)
- fastjson生成和解析json数据
- MVC+Ef项目(1) 项目的框架搭建
- asp.net mvc3+EF4.1项目实战
- SVN安装和使用(简单版)
- VUE 安装及项目创建
- mysql 数据可视化操作---Navicat安装及简单使用
- 如何使用 Yum Repository 安装指定版本的 MySQL
- 【Zookeeper系列】ZooKeeper安装配置(转)
- Python面向对象编程(下)
- python之进程(multiprocess)
- leetcode — longest-substring-without-repeating-characters
- android 不同Activity之间数据传递
- MySql数据库表操作(二)