zoukankan      html  css  js  c++  java
  • 手机重写alert方法(去除网址和关闭网页按钮)

    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";    }}

  • 相关阅读:
    .NET简谈互操作(七:数据封送之介绍)
    C# utf8编码时转换成shiftjis时出现乱码问题的处理
    .NET简谈特性(代码属性)
    著名Channel 9 主持人Robert Green 采访微软一站式示例代码库录像
    SharePoint 2007运行 Edit In DataSheet 时在IE 6下页面卡死的分析和处理方法
    截图工具
    Resharper上手指南
    .NET简谈互操作(三:基础知识之DllImport特性)
    .NET简谈互操作(五:基础知识之提升平台调用性能)
    深度训练(DotNet专场)
  • 原文地址:https://www.cnblogs.com/important/p/7656876.html
Copyright © 2011-2022 走看看