Window.prototype.alert = function(){
  //创建一个大盒子
var box = document.createElement("div");
  //创建一个关闭按钮
var button = document.createElement("button");
  //定义一个对象保存样式
var boxName = {
width:"500px",
height:"180px",
backgroundColor:"#f8f8f8",
border:"1px solid #ccc",
position:"absolute",
top:"50%",
left:"50%",
margin:"-90px 0 0 -250px",
zIndex:"999",
textAlign:"center",
lineHeight:"180px"
}
  //给元素添加元素
for(var k in boxName){
box.style[k] = boxName[k];
}
  //把创建的元素添加到body中
document.body.appendChild(box);
  //把alert传入的内容添加到box中
if(arguments[0]){
box.innerHTML = arguments[0];
}
button.innerHTML = "关闭";
  //定义按钮样式
var btnName = {
border:"1px solid #ccc",
backgroundColor:"#fff",
width:"70px",
height:"30px",
textAlign:"center",
lineHeight:"30px",
outline:"none",
position:"absolute",
bottom:"10px",
right:"20px",
}
for(var j in btnName){
button.style[j] = btnName[j];
}
  //把按钮添加到box中
box.appendChild(button);
  //给按钮添加单击事件
button.addEventListener("click",function(){
box.style.display = "none";
})
} alert("我的好朋友JavaScript```")

重写console.log

console.log = (function(log){
return function(){
log.call(console,"hello:"+(arguments[0]||" "));
}
}(console.log))
console.log("alert");

重写js alert的更多相关文章

  1. 重写JS的鼠标右键点击菜单

    重写JS的鼠标右键点击菜单 该效果主要有三点,一是对重写的下拉菜单的隐藏和显示:二是屏蔽默认的鼠标右键事件:三是鼠标左键点击页面下拉菜单隐藏. 不多说,上html代码: 1 <ul id=&qu ...

  2. 基于js alert confirm样式弹出框

    基于js alert confirm样式弹出框.这是一款根据alert confirm优化样式的确认对话框代码. 在线预览   源码下载 实现的代码. html代码: <div id=" ...

  3. ios调用Html内JS alert 不能点击关闭为甚?

    ios调用Html内JS alert 不能点击关闭为甚? This question gave me the most insight to the problem... Deadlock with ...

  4. bootstrap 重写JS的alert、comfirm函数

    原理是使用bootstrap的Modal插件实现. 一.在前端模板合适的地方,加入Modal展现div元素. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...

  5. js alert重写,适用于手机端,改自于网上的代码

    <!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...

  6. js.alert(重写)

    function dialogFn(Msg, btnOkCallBack, btnCancelCallBack) { $("body").append('<div id=&q ...

  7. 浅谈WebView的使用 js alert

    http://blog.csdn.net/liuhe688/article/details/6549263 WebView是Android中一个非常实用的组件,它和Safai.Chrome一样都是基于 ...

  8. js alert(“”)弹框 自定义样式

    首先用css渲染一个样式 #msg{ height: 2rem; text-align: center; position: fixed; top: 50%; margin-top: -1rem; l ...

  9. .js——alert()语句

    在.js文件中,通过alert()语句可以生成弹出框,弹出框中的内容message部分可以是常量字符串,也可以是含有变量的字符串连接,下面举几个例子简要说明下: 1. 参数为常量字符串 alert(& ...

随机推荐

  1. [原创]配置管理技术圈QQ群:129489184

    [原创]配置管理技术圈QQ群:129489184 配置管理技术圈QQ群:129489184,研究cvs,svn,git,cc等平台配置技术,涉及版本控制,持续集成,自动化构建等! 欢迎各位同学来,来时 ...

  2. 配置editplus,讓其支持代碼自動格式化功能.

    使用editplus已經好多年了,累積了不少的東西,想換IDE比較麻煩,所以就研究了一下用editplus搭配gofmt.exe配置go語言代碼自動格式化的功能.還好功夫不負有心人,終於被我搞懂了,不 ...

  3. Cocos2dx.3x入门三部曲-Hello Game项目解析(三)

    一.前提: 完成Hello Game项目的创建编译. 具体参考:Cocos2dx.3x_Hello Game项目创建篇 二.本篇目标: l  分析proj.win32工程的主要构成 l  分析proj ...

  4. 田渊栋:AlphaGo系统即使在单机上也有职业水平

    Facebook人工智能组研究员田渊栋博士在知乎专栏上更新了一篇文章,详细分析了AlphaGo在<自然>杂志上发表的论文,他认为AlphaGo整个系统即使在单机上也已具有了职业水平,与李世 ...

  5. MySQL 错误

    (1) Ignoring query to other database D:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -Uroot 原因是 ...

  6. A little tutorial on CodeFluent Entities with ASP.NET MVC4

    /* Author: Jiangong SUN */ CodeFluent Entities is a model-first development tool which creates non-s ...

  7. ELK——在 CentOS/Linux 把 Kibana 3.0 部署在 Nginx 1.9.12

    上一篇文章<安装 logstash 2.2.0.elasticsearch 2.2.0 和 Kibana 3.0>,介绍了如何安装 Logstash.Elasticsearch 以及用 P ...

  8. nginx location 的配置

    一.基本语法:location [=|~|~*|^~] /uri/ { … } 二.分类: 1.基本location:以“ = ”或“ ^~ ”为前缀或者没有任何前缀的 /uri/ 2.正则locat ...

  9. redmine v3.02版的安装问题

    redmine v3.0.2版的安装问题 参考上次在朋友公司的云主机上安装的过程: 1. 下载 2. gem install bundler 3. bundle install 出现 rmagick ...

  10. puma vs passenger vs rainbows! vs unicorn vs thin 适用场景 及 performance

    ruby的几个web server,按照开发活跃度.并发方案及要点.适用场景等分析puma vs passenger vs rainbows! vs unicorn vs thin. 1. thin: ...