点击按钮全屏变灰遮罩锁屏效果

1个月前 (04-09 20:02)阅读39回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4529
  • 级别管理员
  • 主题905
  • 回复2
楼主

通过点击按钮实现全屏变暗效果,类似锁屏特效,当用户再次点击时恢复显示,可根据自己的需求来自定义。

<!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>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>点击按钮全屏变灰遮罩锁屏效果_武鸣人</title>
<style type="text/css">
#www_wuming_ren{visibility:hidden;position:fixed;top:0;left:0;z-index:1987;width:100%;height:100%;background:#000;filter:alpha(opacity=70);opacity:0.7;}
/*IE6 fixed*/
* html{background:url(*) fixed;}
* html body{margin:0;height:100%;}
* html #www_wuming_ren{position:absolute;left:expression(documentElement.scrollLeft+documentElement.clientWidth-this.offsetWidth);top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight);}
</style>
<script language="javascript">
(function(){
// 获取对象
var $ = function (id){
return document.getElementById(id);
};
// 遍历
var each = function(a, b) {
for (var i = 0, len = a.length; i < len; i++) b(a[i], i);
};
// 事件绑定
var bind = function (obj, type, fn) {
if (obj.attachEvent) {
obj['e' + type + fn] = fn;
obj[type + fn] = function(){obj['e' + type + fn](window.event);}
obj.attachEvent('on' + type, obj[type + fn]);
} else {
obj.addEventListener(type, fn, false);
};
};
// 移除事件
var unbind = function (obj, type, fn) {
if (obj.detachEvent) {
try {
obj.detachEvent('on' + type, obj[type + fn]);
obj[type + fn] = null;
} catch(_) {};
} else {
obj.removeEventListener(type, fn, false);
};
};
// 阻止浏览器默认行为
var stopDefault = function(e){
e.preventDefault ? e.preventDefault() : e.returnValue = false;
};
// 获取页面滚动条位置
var getPage = function(){
var dd = document.documentElement,
db = document.body;
return {
left: Math.max(dd.scrollLeft, db.scrollLeft),
top: Math.max(dd.scrollTop, db.scrollTop)
};
};
// 锁屏
var lock = {
show: function(){
$('www_wuming_ren').style.visibility = 'visible';
var p = getPage(),
left = p.left,
top = p.top;
// 页面鼠标操作限制
this.mouse = function(evt){
var e = evt || window.event;
stopDefault(e);
scroll(left, top);
};
each(['DOMMouseScroll', 'mousewheel', 'scroll', 'contextmenu'], function(o, i) {
bind(document, o, lock.mouse);
});
// 屏蔽特定按键: F5, Ctrl + R, Ctrl + A, Tab, Up, Down
this.key = function(evt){
var e = evt || window.event,
key = e.keyCode;
if((key == 116) || (e.ctrlKey && key == 82) || (e.ctrlKey && key == 65) || (key == 9) || (key == 38) || (key == 40)) {
try{
e.keyCode = 0;
}catch(_){};
stopDefault(e);
};
};
bind(document, 'keydown', lock.key);
},
close: function(){
$('www_wuming_ren').style.visibility = 'hidden';
each(['DOMMouseScroll', 'mousewheel', 'scroll', 'contextmenu'], function(o, i) {
unbind(document, o, lock.mouse);
});
unbind(document, 'keydown', lock.key);
}
};
bind(window, 'load', function(){
$('wuming_ren').onclick = function(){
lock.show();
};
$('www_wuming_ren').onclick = function(){
lock.close();
};
});
})();
</script>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
<button id="wuming_ren" style="position:absolute;left:50%;top:40%;">开启锁屏</button>
<ol id="test">
  <li>武鸣人,各种信息免费发布,资源共享合作共赢!</li>
</ol>
<div id="www_wuming_ren"></div>
</body>
</html>


0
0
收藏0
回帖

点击按钮全屏变灰遮罩锁屏效果 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息