js alert重写,适用于手机端,改自于网上的代码
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=320,initial-scale=1,maximum-scale=1,user-scalable=no" servergenerated="true" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta content="telephone=no" name="format-detection" />
</head>
<body></body>
</html>
<script>
//改写alert
window.alert = function(txt)
{
var shield = document.createElement("DIV");
shield.id = "shield";
shield.style.position = "absolute";
shield.style.left = "0px";
shield.style.top = "0px";
shield.style.width = "100%";
shield.style.height = "100%";
shield.style.background = "#333";
shield.style.textAlign = "center";
shield.style.zIndex = "19901000";
shield.style.filter = "alpha(opacity=.5)";
shield.style.opacity = ".5";
var alertFram = document.createElement("DIV");
alertFram.id="alertFram";
alertFram.style.position = "absolute";
alertFram.style.left = "25%";
alertFram.style.top = "35%";
alertFram.style.width = "50%";
alertFram.style.background = "#ccc";
alertFram.style.overflow = "hidden";
alertFram.style.textAlign = "center";
alertFram.style.borderRadius = "5px";
alertFram.style.zIndex = "19901024";
strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
strHtml += " <li style=\"background:#FFFFFF;font-size:16px;text-align:center;height:30px;line-height:30px;border-bottom: 1px solid #EBEBEB;\">提 示</li>\n";
strHtml += " <li style=\"padding:20px;background:#fff;text-align:center;font-size:12px;border-bottom: 1px solid #EBEBEB;\">"+txt+"</li>\n";
strHtml += " <li style=\"background:#FFFFFF;text-align:center;font-size:14px;height:30px;line-height:30px;\"><span onclick=\"doOk()\" style=\"width: 50%;cursor: pointer;\">确 定</span></li>\n";
strHtml += "</ul>\n";
alertFram.innerHTML = strHtml;
document.body.appendChild(alertFram);
document.body.appendChild(shield);
var c = 0;
this.doAlpha = function(){
if (c++ > 20){clearInterval(ad);return 0;}
shield.style.filter = "alpha(opacity="+c+")";
shield.style.opacity = ".5";
}
var ad = setInterval("doAlpha()",5);
this.doOk = function(){
//alertFram.style.display = "none";
//shield.style.display = "none";
document.body.removeChild(alertFram);
document.body.removeChild(shield);
}
alertFram.focus();
document.body.onselectstart = function(){return false;};
}
alert(1);
</script>
js alert重写,适用于手机端,改自于网上的代码的更多相关文章
- JS 判断是否是手机端并跳转操作
JS 判断运行当前脚本的应用程序是否为手机端或者一些其他信息,在我的工作中遇到的不是十分频繁,被我的同事一问就给问住了,所以把之前找到的一些知识点整理出来,供大家参考,若哪里不对欢迎指出,我会及时的更 ...
- js判断是否为手机端访问
随着移动端越来越重要,pc和移动端网站后台系统可能是同一个,登录或者某个特定时期需要根据不同访问来源,跳转不同页面或者做不同的处理: 这时我们就需要js的 navigator 对象: 我们先了解一下n ...
- [js开源组件开发]-手机端照片预览组件
手机端照片预览组件 可怜的我用着华为3C手机,用别人现成的组件都好卡,为了适应我这种屌丝,于是自己简化写了一版的照片预览效果,暂时无缩放功能,以后可能有空再加吧,你也可以自己加下,这是个github上 ...
- js判断客户端是手机端还是PC端
封装函数: function isPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", ...
- 【转】自动识别是手机端还是pc端只用一行代码就搞定
<script type="text/javascript"> var mobileAgent = new Array("iphone", &quo ...
- jquery做个日期选择适用于手机端
第一步:做个 文本框用于显示年月日的 第二步:点击文本框触发bootstrap模态框并显示 第三步:我是建一个外部js页面写的 js中获得当前时间是年份和月份,形如:201208 //获取 ...
- js 检查是否为手机端
let isMobile = function(){ let userAgentInfo = navigator.userAgent; let Agents = new Array("And ...
- js如何判断是手机端还是PC端访问
function isMobile(){ var sUserAgent= navigator.userAgent.toLowerCase(), bIsIpad= sUserAgent.match(/i ...
- js.alert(重写)
function dialogFn(Msg, btnOkCallBack, btnCancelCallBack) { $("body").append('<div id=&q ...
随机推荐
- Spring MVC 4.2 增加 CORS 支持 Cross-Origin
基于XML的配置: <mvc:cors> <mvc:mapping path="/api/**" allowed-origins="http://dom ...
- morhia解决BigDecimal映射问题
错误信息:morphia No usable constructor for java.math.BigDecimal 解决办法:增加自定义类型转换器,代码如下 package cn.huilink. ...
- [linux] Nginx编译安装错误error: the HTTP rewrite module requires the PCRE library
nginx编译错误: 执行如下命令安装缺少的文件即可
- Android学习笔记(五)
Intent不仅用来启动一个活动,Intent还可以在启动活动的时候传递参数. 1.向下一个活动传递数据 启动活动的时候传递数据,Intent提供了一系列putExtra()方法的重载,可以把要传递的 ...
- UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout
1,UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的.而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到 UI ...
- Linux 下没有conio.h 已解决
原文:http://blog.sina.com.cn/s/blog_6a95e00b0100zqvf.html #include <stdio.h>//#include <conio ...
- Unity3D学习笔记
双击或F-居中显示对象 Alt-旋转场景 Align With View-正视主镜头 添加质量 使成为预制物体, 即flash中元件, 预制物体在Hierarchy中名字成蓝色, Assets是的对象 ...
- 2014年第五届蓝桥杯C/C++程序设计本科B组决赛
1.年龄巧合(枚举) 2.出栈次序(推公式/Catalan数) 3.信号匹配(kmp) 4.生物芯片(完全平方数) 5.Log大侠(线段树) 6.殖民地 1.年龄巧合 小明和他的表弟一起去看电影,有人 ...
- 异常Throwable类
所有异常类型都是Throwable类的子类,它派生出两个子类 Error和Exception Error类:表示紧靠程序本身无法恢复的严重错误,如内存溢出,动态链接失败,虚拟机错误 ...
- HTML中行内元素与块级元素的区别
块级元素:独占一行,可设宽高,内外边距:块级元素有form,p,h1到h6,ol ,ul ,dl和dd和dt ,hr,li,pre,caption ,div ,table ,tr ,td ,th等. ...