//重写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()弹窗的更多相关文章

  1. JS重写alert,保证弹窗错误的友好性

    // ------------------------------------------------------------- // 重写alert,保证弹窗错误的友好性 var j_oldAler ...

  2. 原生 js 模拟 alert 弹窗

    复制头部的 js 代码到你的 js 文件的任何地方,调用Chef.alert方法传入相应的参数即可并没有什么功能,只是一个提示的作用,可能样式比 alert 的弹窗好看点,css是写在js里的,只要你 ...

  3. CEF拦截js层alert弹窗 OnJSDialog 《转》

    一 引言 CEF3嵌入后,用JS 弹出Alert框,按钮错位,确定按钮勉强能看到.很难看.为了改善体验,决定重写提示框. 环境:VS2008  VC  MFC.   二 原理 参看类 CefJSDia ...

  4. JS 重写alert,使之能输出多个参数

    windows._alert = windows.alert; windows.alert = function(){ _alert = (Array.prototype.slice(argument ...

  5. js 重写alert 兼容iphone使得alert 不带src

    <script> window.alert = function(name){ var iframe = document.createElement("IFRAME" ...

  6. [Winform]Cefsharp重写alert与confirm弹窗

    摘要 在使用winform内嵌cefsharp浏览本地页面的时候,如果出现alert弹窗,会在标题栏显示页面所在目录.所以想起来重写alert的样式,通过winform的MessageBox进行提示. ...

  7. Cef 重写alert与confirm弹窗

    在使用form内嵌cef浏览本地页面的时候,如果出现alert弹窗,会在标题栏显示页面所在目录.所以想起来重写alert的样式,通过MessageBox进行提示,或者自己写一个弹窗. 以下代码基于 3 ...

  8. 修改js confirm alert 提示框文字的简单实例

    修改js confirm alert 提示框文字的简单实例: <!DOCTYPE html> <html> <head lang="en"> & ...

  9. 移动端开发(使用webuploader上传图片,客户端交互,修改alert弹窗等)

    之前实习做的一个移动端的页面 需要的功能有图片上传 点击客户端的返回按钮 有提示(即与客户端有交互) 遇到不少的坑 总结一下问题 1.图片上传功能  使用工具 百度的webuploader 暂时遇到的 ...

随机推荐

  1. Writing Code-Codeforces511C**

    http://codeforces.com/problemset/problem/544/C 完全背包 dp[i][j]表示第i行有j个bug #include<stdio.h> #inc ...

  2. linux下crontab安装和使用(定时任务)

    在Unix和Linux的操作系统之中,cron可以让系统在指定的时间,去执行某个指定的任务,crontab命令常用于管理对应的cron. 一.crontab在线安装 yum -y install vi ...

  3. MongoDB集群搭建教程收集(待实践)

    先收集,后续再实践. MongoDB的集群应该和MySQL的定位保持一致,因为要认为它就是一个数据库. 集群方式有也是有很多,比如分库,分片,主从,主主等等. 下面是收集的一些教程: http://b ...

  4. JS中的apply、call、bind区别

    apply.call.bind 用法 1:作用 改变函数运行时的上下文,即改变this的指向问题. xxxFunction.call(this,arg1,arg2,arg3); xxxFunction ...

  5. python 交互模式 方向键乱码问题解决

    python交互模式下通常用向上键来找到之前执行的命令,用左右键移动光标.这很方便.但有的时候这些键在按完后却会出现乱码. 本文只解决CentOS 6.4 下 python2.7.8 的乱码问题. 这 ...

  6. android 深入浅出 群内“每日一问” 问答总结

    永远不变的就是变. 俗话说的好,环境改变人生. 常常面对的是一群积极奋进的人,那么你的心态和生活也会变的充满斗志.青春在于折腾,趁我们还年轻,拿出你的激情.踏着泪水载着梦,才干拥有自己的一片天空. 上 ...

  7. sum over使用方法,以及与group by的差别

    1.sum over使用方法 sum(col1) over(partition by col2 order by col3 ) 以上的函数能够理解为:按col2 进行分组(partition ),每组 ...

  8. A星算法(Java实现)

    一.适用场景 在一张地图中.绘制从起点移动到终点的最优路径,地图中会有障碍物.必须绕开障碍物. 二.算法思路 1. 回溯法得到路径 (假设有路径)採用"结点与结点的父节点"的关系从 ...

  9. cocos2d-x2.2.5走四棋儿源代码“开源”

    尊重开发人员的劳动成果.转载请注明From郝萌主 游戏简单介绍: 一款益智棋类游戏,通过两枚棋子对上敌方的一枚棋子便可击杀对方. 游戏界面精美简洁,游戏规则简单明了,AI聪明有趣. 人人对战,人机对战 ...

  10. ios打地鼠游戏源代码

    打地鼠游戏源代码,游戏是一款多关卡基于cocos2d的iPad打地鼠游戏源代码,这也是一款高质量的打地鼠游戏源代码,能够拥有逐步上升的关卡的设置,大家能够在关卡时设置一些商业化的模式来盈利的,很完美的 ...