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. ecshop2.72文件结构说明

    ECShop 2.7.2 的结构图及各文件相应功能介绍 ECShop 2.7.2 upload 的目录┣ activity.php 活动列表┣ affiche.php 广告处理文件┣ affiliat ...

  2. MapReduce之单词计数

    最近在看google那篇经典的MapReduce论文,中文版可以参考孟岩推荐的 mapreduce 中文版 中文翻译 论文中提到,MapReduce的编程模型就是: 计算利用一个输入key/value ...

  3. Leetcode 303 Range Sum Query - Immutable

    题意:查询一个数组在(i,j]范围内的元素的和. 思路非常简单,做个预处理,打个表就好 拓展:可以使用树状数组来完成该统计,算法复杂度为(logn),该数据结构强力的地方是实现简单,而且能完成实时更新 ...

  4. python find函数

    Python find() 方法检测字符串中是否包含子字符串 str ,如果指定 beg(开始) 和 end(结束) 范围,则检查是否包含在指定范围内,如果包含子字符串返回开始的索引值,否则返回-1 ...

  5. adb uninstall

    adb shell pm list packages adb uninstall com.pa.pfac

  6. 【CUDA学习】共享存储器

    下面简单介绍一些cuda中的共享存储器和全局存储器 共享存储器,shared memory,可以被同一块中的所有线程访问的可读写存储器,生存期是块的生命期. Tesla的每个SM拥有16KB共享存储器 ...

  7. 【转】升级Xcode6.3插件失效解决办法

     1.打开终端,输入以下代码获取到DVTPlugInCompatibilityUUID         defaults read /Applications/Xcode.app/Contents/I ...

  8. ThinkBox DOC

    插件源码下载 @github https://github.com/Aoiujz/ThinkBox.git 插件使用方法 引入文件 //使用ThinkBox弹出框必须引入以上三个文件. //jQuer ...

  9. eclipse web项目转maven项目

    ps:好久没写博客了,工作了人就懒了,加油加油,up,up 1 eclipse web项目目录 /web app src com.xx.xx *.properties *.xml WebRoot ​W ...

  10. 基于 Quartz 开发企业级任务调度应用

    原文地址:http://www.ibm.com/developerworks/cn/opensource/os-cn-quartz/index.html Quartz 基本概念及原理 Quartz S ...