JavaScript仿Windows关机效果

本文介绍了一种使用JavaScript实现的页面弹窗效果,通过创建和操作DOM元素来展示带有自定义样式的提示信息。该方法考虑了不同屏幕尺寸的适配,并在显示提示窗口的同时暂时隐藏了页面上的下拉框等交互元素。
部署运行你感兴趣的模型镜像
<script>
 function msg(info){
 var p=document.createElement("DIV");
 if (!info) var info='谢谢支持ajax中国';
 p.id="p";
 p.style.position="absolute";
 p.style.width=document.body.scrollWidth;
 p.style.height=(document.body.offsetHeight>document.body.scrollHeight)?'100%':document.body.scrollHeight;
 p.style.zIndex='998';
 p.style.top='0px';
  p.style.left='0%';
 p.style.backgroundColor="gray";
 p.style.opacity='0.5';
 p.style.filter="alpha(opacity=80)";
 document.body.appendChild(p);
 var p1=document.createElement("DIV");
 var top=parseInt(parseInt(document.body.scrollHeight)*0.25)+document.body.scrollTop;
 p1.style.position="absolute";
 p1.style.width="300px";
 p1.id="p1";
 var left=Math.ceil(((document.body.scrollWidth)-parseInt(p1.style.width.replace('px','')))/2)+document.body.scrollLeft;
 p1.style.height="200px";
 p1.style.zIndex='999'; 
 p1.style.top=top+'px';
  p1.style.left=left+'px';
 p1.style.border="0px solid red";
 var html="";
  html+="<center>"
  html+="<div class='p3' style='height:1px;overflow:hidden;background:red;width:294px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p2' style='height:1px;overflow:hidden;background:red;width:296px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p2' style='height:1px;overflow:hidden;background:red;width:298px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p1' style='height:20px;overflow:hidden;background:red;width:300px;border-left:1px solid red;border-right:1px solid red;color:#fff;font-size:9pt;font-weight:bold;text-align:left;'> ⊙ 提示</div>"
 html+="<div id='c' style='height:150px;width:300px;background-color:#FEEACB;overflow:hidden;border-left:1px solid red;border-right:1px solid red;padding-top:40px;font-size:9pt;'>"+info+"<br><br><br>[ <a href='javascript:this.cancle()'>关闭</a> ]</div>"
  html+="<div class='p1' style='height:1px;overflow:hidden;background:#FEEACB;width:298px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p2' style='height:1px;overflow:hidden;background:#FEEACB;width:296px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p3' style='height:1px;overflow:hidden;background:red;width:294px;border-left:1px solid red;border-right:1px solid red'></div>"
  html+="</center>"
 document.body.appendChild(p1);
 p1.innerHTML=html;
 var arr=document.getElementsByTagName("select");
 var i=0;
 while(i<arr.length){
   arr[i].style.visibility='hidden';
   i++;
 }
 this.cancle=function(){
  document.body.removeChild(document.getElementById('p'));
  document.body.removeChild(document.getElementById('p1'));
  var arr=document.getElementsByTagName("select");
   var i=0;
   while(i<arr.length){
   arr[i].style.visibility='visible';
   i++;
   }
 }
}
 </script>
 <input value='shout Down' type='button' onClick='msg()' />

您可能感兴趣的与本文相关的镜像

Dify

Dify

AI应用
Agent编排

Dify 是一款开源的大语言模型(LLM)应用开发平台,它结合了 后端即服务(Backend as a Service) 和LLMOps 的理念,让开发者能快速、高效地构建和部署生产级的生成式AI应用。 它提供了包含模型兼容支持、Prompt 编排界面、RAG 引擎、Agent 框架、工作流编排等核心技术栈,并且提供了易用的界面和API,让技术和非技术人员都能参与到AI应用的开发过程中

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值