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 暂时遇到的 ...
随机推荐
- hdu5618(cdq分治求三维偏序)
题意:给n(n<=100000)个点,坐标为(xi,yi,zi)(1<=xi,yi,zi<=100000),定义一个点A比一个点B小,当且仅当xA<=xB,yA<=yB, ...
- 我的arcgis培训照片7
来自:http://www.cioiot.com/successview-553-1.html
- git fetch 和 git pull 的差别
Git中从远程的分支获取最新的版本号到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本号到本地,不会自己主动merge git fetch origin master git ...
- 关于使用data()获取自定义属性出现undefined的说明
这应该是这个函数的一个bug,没有考虑到驼峰式的写法,当我写成驼峰式,即是有大小写的变量时就会出现没有定义的情况. 今天写个交互,需要用到自定义属性,因为这个自定义属性是当作字段用的,就直接用了字段名 ...
- openstack (4)---部署Glance镜像服务,Nova计算服务
一.Glance Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等. Glance提供Restful API可以查询虚拟机镜像的metadata及获取 ...
- C#在Linux下获取文件夹信息(所在磁盘总大小,使用空间,已用空间,使用率)
1.第一种使用shell命令实现: private DiskInfo LinuxGetFolderDiskInfo(string path) { DiskInfo disk = new DiskInf ...
- WindowFromPoint -- 获得包括指定点的窗体的句柄
WindowFromPoint 函数功能: 该函数获得包括指定点的窗体的句柄. 函数原型: HWND WindowFromPoint(POINT Point): 參数: Point:指定一个被检 ...
- 打开google 新地址
还在为谷歌打不开而发愁吗? 那就试试这个吧 91.213.30.151
- 在Android程序中使用已有的SQLite数据库
已经将这篇文章迁移至 Code问答,你也能够到这里查看这篇文章,请多多关注我的新技术博客CodeWenDa.com 在中文搜索中,没有找到一篇比較好的关于怎样在Android应用中使用自己事先创建好的 ...
- list-style样式不显示问题
<li> display要使用 list-item ,不要使用block,要不然会造成不显示的问题.