zoukankan      html  css  js  c++  java
  • 重写js alert

    Window.prototype.alert = function(){
      //创建一个大盒子
    var box = document.createElement("div");
      //创建一个关闭按钮
    var button = document.createElement("button");
      //定义一个对象保存样式
    var boxName = { "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", "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");
  • 相关阅读:
    EL表达式遍历方法之一
    django auth认证
    总结五个在办公中使用很爽的软件
    django所遇到问题简单总结
    django 远程数据库mysql migrate失败报error 1045之 解决方案
    深拷贝和浅拷贝之地址改变
    序列表转换成横向菜单
    Pycharm破解
    css里涉及到定位相关的example实例
    记录求职
  • 原文地址:https://www.cnblogs.com/pssp/p/5246133.html
Copyright © 2011-2022 走看看