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 ...
随机推荐
- 聊一下JS中的作用域scope和闭包closure
聊一下JS中的作用域scope和闭包closure scope和closure是javascript中两个非常关键的概念,前者JS用多了还比较好理解,closure就不一样了.我就被这个概念困扰了很久 ...
- 基于Open vSwitch搭建虚拟路由器
As part of my work in OpenDaylight, we are looking at creating a router using Open vSwitch... Why? W ...
- 写MYSQL存储过程遇到的一个小BUG
DELIMITER $$ USE `income_new`$$ DROP PROCEDURE IF EXISTS `a`$$ CREATE DEFINER=`income_new`@`%` PROCE ...
- 在Label中显示一段文字
Let’s create a new Xamarin.Forms PCL solution, named Greetings, using the same process described abo ...
- web.xml 文件配置01
web.xml 文件配置01 前言:一般的web工程中都会用到web.xml,方便开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web. ...
- CRM 2016 js 奇怪现象
假如 js 中如果定义了 两个字段的onchage 事件. 如果一个字段的onchange事件,改变了另一个字段的值,那么也会触发另一个字段的onchange事件!!!!????
- 面向对于javascript编程
以构造函数的方式定义对象 function Person(name, age) { this.name = name; this.age = age; this.sayName = function ...
- Sonar升级遇到的那些事儿
目录 背景 如何升级 如何回滚 问题解决 参考 背景 目前我们用SonarQube版本是4.0,这次准备升级到最新版本5.1, 以便支持以后的JavaScript的项目. 如何升级 我们可以直接跨越版 ...
- strong reference cycle in block
However, because the reference is weak, the object that self points to could be deallocated while th ...
- hive和ORACLE语法对比