重写Alert

重写Alert

 

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta charset="UTF-8">
 5 <title>Insert title here</title>
 6 <script type="text/javascript">
 7 var orginalert = window.alert;
 8 window.alert = function(message){
 9     var frm = document.frm;
10     frm.action = "./popup.html";
11     var winpop = window.open("","targetopoup","width=700,height=500,location=no,resizable=no");//top=0,left=0,
12     frm.target = "targetopoup";
13     frm.submit();
14     frm.target = "";
15     winpop.focus();
16 }
17 
18 function originbuttonclick(){
19     
20     orginalert("orginalert");
21 }
22 function resetbuttonclick(){
23     
24     alert("orginalert");
25 }
26 </script>
27 </head>
28 <body>
29 <input type="button" value="originbutton" onclick="originbuttonclick()"> 
30 <input type="button" value="resetbutton" onclick="resetbuttonclick()"> 
31 <form action="" id = "frm" name="frm">
32 
33 </form>
34 </body>
35 </html>

 

 

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta charset="UTF-8">
 5 <title>Insert title here</title>
 6 <script type="text/javascript">
 7 function testload(){
 8     //alert("3434");
 9     window.moveTo(0,0);        
10     window.resizeTo(screen.availWidth,screen.availHeight); 
11     window.outerWidth=screen.availWidth;        
12     window.outerHeight=screen.availHeight;
13 }
14 </script>
15 </head>
16 <body onload="testload()">
17 <h1>hahah</h1>
18 </body>
19 </html>

 

转载于:https://www.cnblogs.com/mingluosunshan/p/5287703.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用JavaScript和CSS来创建一个自定义的Alert弹出框,并使用setTimeout函数来使其在一段时间后自动消失。 首先,您可以使用以下HTML代码创建一个弹出框的框架: ```html <div id="myAlert" class="alert"> <span class="closebtn" onclick="closeAlert()">×</span> <strong>Alert:</strong> This is a custom alert box. </div> ``` 然后,您可以使用以下CSS样式来自定义弹出框的样式: ```css .alert { padding: 20px; background-color: #f44336; color: white; border-radius: 5px; position: fixed; bottom: 0; right: 0; margin-right: 20px; margin-bottom: 20px; z-index: 9999; animation: slidein 0.5s, fadeout 0.5s 2.5s; } .closebtn { margin-left: 15px; color: white; font-weight: bold; float: right; font-size: 22px; line-height: 20px; cursor: pointer; transition: 0.3s; } .closebtn:hover { color: black; } @keyframes slidein { from {bottom: -100px; opacity: 0;} to {bottom: 0; opacity: 1;} } @keyframes fadeout { from {opacity: 1;} to {opacity: 0;} } ``` 最后,您可以使用以下JavaScript代码来显示和关闭弹出框,并设置setTimeout函数来在一段时间后自动关闭弹出框: ```javascript function showAlert() { var alertBox = document.getElementById("myAlert"); alertBox.style.display = "block"; setTimeout(function(){ alertBox.style.display = "none"; }, 3000); } function closeAlert() { var alertBox = document.getElementById("myAlert"); alertBox.style.display = "none"; } ``` 通过调用showAlert函数,您可以显示一个自定义的Alert弹出框,并在3秒后自动关闭。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值