zoukankan      html  css  js  c++  java
  • ie使用JS实现console

    调试js的时候 , ff,chrome,safari 浏览器中有console可以在控制台打印一些信息 , ie是没有这个console对象,故写了个console以便调试使用,仅仅实现了log方法。淘宝女装夏装新款

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8"/>
    </head>
    <body>
    112342134<br/>
    112342134<br/>
    112342134<br/>
    112342134<br/>
    112342134<br/>
    112342134<br/>
    </body>


    <script>
    if(!window.console){
        console = (function(){
            var instance = null;
            function Constructor(){
                this.div = document.createElement("console");
                this.div.id = "console";
                this.div.style.cssText = "filter:alpha(opacity=80);position:absolute;top:0px;left:0px;100%;border:1px solid #ccc;background:#eee;";
                document.body.appendChild(this.div);
            }
            Constructor.prototype = {
                log : function(str){
                    var p = document.createElement("p");
                    p.innerHTML = str;
                    this.div.appendChild(p);坏帐
                }
            }
            function getInstance(){
                if(instance == null){
                    instance =  new Constructor();
                }
                return instance;
            }
            return getInstance();
        })()
    }

    console.log("444");
    console.log("555");
    console.log("666");
    console.log("777");

    </script>
    </html>

  • 相关阅读:
    php 实现四种排序两种查找
    GIT常用命令
    2016-the brave never die
    Apache 的ab压力测试工具
    SQL语句优化实践
    C#设计模式:访问者模式(Vistor Pattern)
    泛型反射性能优化
    C#GC垃圾回收和析构函数和IDisposable的使用
    C#配合大数据开发,nest.dll的使用
    C#导出大量数据到excel,怎么提升性能
  • 原文地址:https://www.cnblogs.com/sky7034/p/2049575.html
Copyright © 2011-2022 走看看