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 ...
随机推荐
- putty连接ubuntu虚拟机缓慢问题的解决
vmware安装系统使用了ubuntu,安装后每次用PUTTY登录发现都到等很久,经过上网搜索,发现是Ubuntu安全机制导致的连接缓慢问题, 解决方法如下; 1. sudo vim /etc ...
- Git+Github代码管理控制
关于Git的发展历程这里就不多介绍了,有兴趣的话可以查阅一下Git的相关历程. 如果你在做的项目或者自己写的一些项目由于需要用的分布式.或者团队开发.再或者你不善于对代码进行定期备份,但又希望自己的代 ...
- Linxu IO测试软件
fio 安装 apt-get install fio fdisk -l Device Boot Start End Blocks Id System/dev/sda1 * 2048 968390655 ...
- R中,定义一个长度为0的向量
定义一个长度为0的向量 > x<-c()> length(x)[1] 0 修改该向量的类型 > class(x)="numeric"> class(x ...
- mysql按月获取一年内每个月的数据量
SELECT COUNT(id) AS num, DATE_FORMAT(create_time, '%Y-%m') AS createTime FROM table WHERE create_tim ...
- firefox与IE对js和CSS的区别(转http://log-cd.javaeye.com/blog/548665)
? "700px" : document.body.clientWidth>1000 ? "1000px" : "auto");// ...
- 【C-001】printf理解
输出整型的数值就不说了, 显示浮点型: printf("%.2f",3.33); //保留两位小数显示,数字前面没有空格填充 显示的时候,设计到0-1之间的数的时候: printf ...
- Matrix的一些知识
1.什么是ColorMatrix ColorMatrix是一个颜色矩阵,它定义了一个 4*5 的float[]类型的矩阵 颜色矩阵,而图像的 RGBA 值则存储在一个5*1的颜色分量矩阵C中 所以为了 ...
- spring读写分离
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; public class ChooseData ...
- 自己练习读取写入txt
读取文件中的内容生成一个list,然后修改list后再写会该文件文件中的格式是:AA,BB,CC,DDblist = []for line in open('a.txt'): blist.extend ...