js重写alert()弹窗
//重写alert
window.alert = function(str)
{
var alertFram = document.getElementById('alertFram');
var shield = document.createElement("DIV");
shield.id = "shield";
shield.style.position = "absolute";
shield.style.left = "50%";
shield.style.top = "50%";
shield.style.width = "300px";
shield.style.height = "300px";
shield.style.marginLeft = "-150px";
shield.style.marginTop = "-150px";
shield.style.zIndex = "25";
if( !alertFram ) { //防止重复弹出两个弹窗,且不能关闭
alertFram = document.createElement("DIV");
alertFram.id = "alertFram";
alertFram.style.position = "fixed";
alertFram.style.width = "300px";
alertFram.style.height = "200px";
alertFram.style.left = "50%";
alertFram.style.top = "0";
alertFram.style.marginLeft = "-150px";
alertFram.style.marginTop = "30px";
alertFram.style.textAlign = "center";
alertFram.style.lineHeight = "150px";
alertFram.style.zIndex = "1100";
document.body.appendChild(alertFram);
document.body.appendChild(shield);
}else{
alertFram.style.display = "";
shield.style.display = "";
}
strHtml = '<div class="alert_ul" style="list-style:none;margin:0px;padding:0px;width:100%;">';
strHtml += '<p class="alert_title" style="background: #fff;letter-spacing: 2px;text-align: left;padding-left: 20px;line-height: 50px;font-size: 20px;border-top: 1px solid #91AFA5;border-left: 1px solid #91AFA5;border-right: 1px solid #91AFA5;border-top-left-radius: 3px;border-top-right-radius: 3px;">消息提示</p>';
strHtml += '<p class="alert_content" style="background: #fff;text-align: left;height: auto;color: #999;line-height: 25px;font-size: 14px;letter-spacing: 2px;padding: 0 20px 25px;border-left: 1px solid #91AFA5;border-right: 1px solid #91AFA5;">'+str+'</p>';
strHtml += '<p class="alert_btn_wrap" style="background: #fff;line-height: 25px;padding: 0 18px 18px;border-left: 1px solid #91AFA5;border-right: 1px solid #91AFA5;border-bottom: 1px solid #91AFA5;border-bottom-left-radius: 3px;border-bottom-right-radius: 3px;"><input type="button" value="确 定" onclick="doOk()" class="alert_btn" style="border: none;outline: none; -moz-appearance: none; -webkit-appearance: none;appearance:none;width:80px;height:40px;background:#44E7BA;border-radius: 3px;;cursor:pointer;color:#fff; -webkit-transition: background 0.2s;transition: background 0.2s;font-size: 16px;"/></p>';
strHtml += '</div>';
alertFram.innerHTML = strHtml; this.doOk = function(){
alertFram.style.display = "none";
shield.style.display = "none";
}
alertFram.focus();
document.body.onselectstart = function(){return false;};
}
js重写alert()弹窗的更多相关文章
- JS重写alert,保证弹窗错误的友好性
// ------------------------------------------------------------- // 重写alert,保证弹窗错误的友好性 var j_oldAler ...
- 原生 js 模拟 alert 弹窗
复制头部的 js 代码到你的 js 文件的任何地方,调用Chef.alert方法传入相应的参数即可并没有什么功能,只是一个提示的作用,可能样式比 alert 的弹窗好看点,css是写在js里的,只要你 ...
- CEF拦截js层alert弹窗 OnJSDialog 《转》
一 引言 CEF3嵌入后,用JS 弹出Alert框,按钮错位,确定按钮勉强能看到.很难看.为了改善体验,决定重写提示框. 环境:VS2008 VC MFC. 二 原理 参看类 CefJSDia ...
- JS 重写alert,使之能输出多个参数
windows._alert = windows.alert; windows.alert = function(){ _alert = (Array.prototype.slice(argument ...
- js 重写alert 兼容iphone使得alert 不带src
<script> window.alert = function(name){ var iframe = document.createElement("IFRAME" ...
- [Winform]Cefsharp重写alert与confirm弹窗
摘要 在使用winform内嵌cefsharp浏览本地页面的时候,如果出现alert弹窗,会在标题栏显示页面所在目录.所以想起来重写alert的样式,通过winform的MessageBox进行提示. ...
- Cef 重写alert与confirm弹窗
在使用form内嵌cef浏览本地页面的时候,如果出现alert弹窗,会在标题栏显示页面所在目录.所以想起来重写alert的样式,通过MessageBox进行提示,或者自己写一个弹窗. 以下代码基于 3 ...
- 修改js confirm alert 提示框文字的简单实例
修改js confirm alert 提示框文字的简单实例: <!DOCTYPE html> <html> <head lang="en"> & ...
- 移动端开发(使用webuploader上传图片,客户端交互,修改alert弹窗等)
之前实习做的一个移动端的页面 需要的功能有图片上传 点击客户端的返回按钮 有提示(即与客户端有交互) 遇到不少的坑 总结一下问题 1.图片上传功能 使用工具 百度的webuploader 暂时遇到的 ...
随机推荐
- Ubuntu 16.04安装TortoiseSVN(基于CrossOver)
基于CrossOver的TortoiseSVN有如下缺点: 1.不能像Windows下实现右键菜单提交,但是可以通过TortoiseSVN实现迁出代码. 可以解决的问题: 1.可以通过Tortoise ...
- python dos2unix
有时你在windows上创建的文件拿到Linux/unix上运行会出错, 这是因为windows上有些字符如换行符在linux/unix不识别.这种情况下需要用dos2unix这个工具把文件转换成li ...
- Rust 1.7.0 macro宏的复用 #[macro_use]的使用方法
Rust 1.7.0 中的宏使用范围包含三种情况: 第一种情况是宏定义在当前文件里.这个文件可能是 crate 默认的 module,也可能是随意的 module 模块. 另外一种情况是宏定义在当前 ...
- day2-搭建hdfs分布式集群
1.搭建hdfs分布式集群 4.1 hdfs集群组成结构: 4.2 安装hdfs集群的具体步骤: 一.首先需要准备N台linux服务器 学习阶段,用虚拟机即可! 先准备4台虚拟机:1个namenode ...
- struts1与struts2的差别
Struts 2是Struts的下一代产品,是在 struts 1和WebWork的技术基础上进行了合并的全新的Struts 2框架.其全新的Struts 2的体系结构与Struts 1的体系结 ...
- android自己定义控件系列教程----视图
理解android视图 对于android设备我们所示区域事实上和它在底层的绘制有着非常大的关系,非常多时候我们都仅仅关心我们所示,那么在底层一点它究竟是怎么样的一个东西呢?让我们先来看看这个图. w ...
- C++之new和malloc差别
在C++程序猿面试中.非常easy被问到new 和 malloc的差别.偶尔在quora上逛.看到Robert Love的总结.才发现自己仅仅知道里面的一两项就沾沾自喜,从来没有像这位大牛一 ...
- 20170623_oracle_优化与体系结构
一般优化技巧 建议不用"*"代替所有列名 删除所有数据用TRUNCATE代替DELETE 用NOT EXISTS 代替NOT IN 用EXISTS代替IN 用EXISTS代替DIS ...
- Error Handling Functions(微软对于出错的情况下提供的所有函数,比如SetThreadErrorMode,SetErrorMode,SetLastErrorEx,FatalAppExit,CaptureStackbackTrace)
The following functions are used with error handling. Function Description Beep Generates simple ton ...
- libjpeg交叉编译
下载libjpeg http://libjpeg.sourceforge.net/ 解压tar -zxf jpegsrc.v6b.tar.gz cd jpeg-6b cp /usr/bin/libto ...