important

js代码

/*重写alert方法*/
	 	window.alert = function(str)
		{
		    
		    var alertFram = document.createElement("DIV");
		    alertFram.id="alertFram";
		    alertFram.style.position = "fixed";
		    alertFram.style.width = "100%";
		    alertFram.style.height = "100%";
		    alertFram.style.top = "0";
		    alertFram.style.textAlign = "center";
		    alertFram.style.lineHeight = "150px";
		    alertFram.style.zIndex = "300";
		    alertFram.style.backgroundColor="rgba(0, 0, 0, 0.58)";
		    alertFram.style.fontSize="12px";
		    strHtml = \'<ul class="alert_ul">\';
		    strHtml += \'<li class="alert_content">\'+str+\'</li>\';
		    strHtml += \'<li class="alert_btn-wrap"><a type="button" value="确定" onclick="doOk()" class="alert_btn">确定</a></li>\';
		    strHtml += \'</ul>\';
		    alertFram.innerHTML = strHtml;
		    document.body.appendChild(alertFram);
		    this.doOk = function(){
		        alertFram.style.display = "none";
		    }
		}

  css渲染

.alert_ul{list-style:none;margin:0px;padding:0px;width:70%;margin: auto;margin-top: 53%;}
.alert_title{background:#F2F2F2;text-align:left;padding-left:20px;line-height:60px;border:1px solid #999;}
.alert_content{background:#fff;text-align:center;height:80px;line-height:80px;}
.alert_btn-wrap{background:#fff;text-align:center;height:30px;line-height:18px;}
.alert_btn{cursor:pointer;color:#2bd00f;}

使用方法:

  加入css和js,直接编写;

alert("推荐失败,请重新操作。");

  

/*重写alert方法*/ window.alert = function(str){        var alertFram = document.createElement("DIV");    alertFram.id="alertFram";    alertFram.style.position = "fixed";    alertFram.style.width = "100%";    alertFram.style.height = "100%";    alertFram.style.top = "0";    alertFram.style.textAlign = "center";    alertFram.style.lineHeight = "150px";    alertFram.style.zIndex = "300";    alertFram.style.backgroundColor="rgba(0, 0, 0, 0.58)";    alertFram.style.fontSize="12px";    strHtml = \'<ul class="alert_ul">\';    strHtml += \'<li class="alert_content">\'+str+\'</li>\';    strHtml += \'<li class="alert_btn-wrap"><a type="button" value="确定" onclick="doOk()" class="alert_btn">确定</a></li>\';    strHtml += \'</ul>\';    alertFram.innerHTML = strHtml;    document.body.appendChild(alertFram);    this.doOk = function(){        alertFram.style.display = "none";    }}

分类:

技术点:

相关文章:

  • 2021-12-26
  • 2021-09-19
  • 2021-11-05
  • 2021-10-16
  • 2021-09-30
  • 2021-11-14
  • 2020-07-06
  • 2021-08-17
猜你喜欢
  • 2021-11-28
  • 2021-08-17
  • 2021-09-08
  • 2021-12-04
  • 2021-09-16
  • 2019-09-11
相关资源
相似解决方案