最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

重点分析JavaScript重写alert()方法的技巧

来源:懂视网 责编:小采 时间:2020-11-27 19:48:59
文档

重点分析JavaScript重写alert()方法的技巧

重点分析JavaScript重写alert()方法的技巧:重点分析JavaScript重写alert()方法的技巧window.alert = function(str) { var alertBox = document.createElement("div"); alertBox.id="alertBox"; alertBox.style.position =
推荐度:
导读重点分析JavaScript重写alert()方法的技巧:重点分析JavaScript重写alert()方法的技巧window.alert = function(str) { var alertBox = document.createElement("div"); alertBox.id="alertBox"; alertBox.style.position =

重点分析JavaScript重写alert()方法的技巧

window.alert = function(str) { 
 var alertBox = document.createElement("div"); 
 alertBox.id="alertBox"; 
 alertBox.style.position = "absolute"; 
 alertBox.style.width = "400px"; 
 alertBox.style.background = "#F2F2F2"; 
 alertBox.style.border = "1px solid grey"; 
 alertBox.style.left = "50%"; 
 alertBox.style.top = "50%"; 
 alertBox.style.transform = "translate(-50%, -50%)"; 
 alertBox.style.textAlign = "center"; 
 alertBox.style.zIndex = "100"; 
 var strHtml = ""; 
 strHtml += '<div id="title">提示:<div id="close" onclick="certainFunc()"></div></div>'; 
 strHtml += '<div id="content">'+str+'</div>'; 
 strHtml += '<div id="certain"><input id="btn" type="button" value="确 定" onclick="certainFunc()" onhover="hoverFunc()"/></div>'; 
 alertBox.innerHTML = strHtml; 
 document.body.appendChild(alertBox); 
 var title = document.getElementById("title"); 
 title.style.textAlign = "left"; 
 title.style.marginTop = "20px"; 
 title.style.paddingLeft = "20px"; 
 title.style.height = "30px"; 
 title.style.fontSize = "15px"; 
 var close = document.getElementById("close"); 
 close.style.width = "16px"; 
 close.style.height = "16px"; 
 close.style.marginRight = "20px"; 
 close.style.background = "url('images/close.png')"; 
 close.style.float = "right"; 
 var content = document.getElementById("content"); 
 content.style.margin = "20px"; 
 content.style.fontSize = "12px"; 
 var certain = document.getElementById("certain"); 
 certain.style.position = "relative"; 
 certain.style.height = "50px"; 
 certainFunc = function() { 
 alertBox.parentNode.removeChild(alertBox); 
 }; 
 var btn = document.getElementById("btn"); 
 btn.style.width = "60px"; 
 btn.style.height = "30px"; 
 btn.style.background = "#cccccc"; 
 btn.style.border = "1px solid grey"; 
 btn.style.position = "absolute"; 
 btn.style.borderRadius = "5px"; 
 btn.style.right = "20px"; 
 btn.style.bottom = "20px"; 
 btn.style.marginTop = "10px"; 
 btn.style.cursor = "pointer"; 
 btn.style.color = "#333"; 
 hoverFunc = function() { 
 btn.style.border = "1px blue solid"; 
 }; 
}

上面是我整理的重点分析JavaScript重写alert()方法的技巧给大家的,希望今后会对大家有帮助。

相关文章:

js解析数据技巧总结

原生JS封装淡入淡出效果函数步骤详解

在vue项目中使用sass的配置方法_vue.js

文档

重点分析JavaScript重写alert()方法的技巧

重点分析JavaScript重写alert()方法的技巧:重点分析JavaScript重写alert()方法的技巧window.alert = function(str) { var alertBox = document.createElement("div"); alertBox.id="alertBox"; alertBox.style.position =
推荐度:
标签: 方法 技巧 js
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top