ie使用JS实现console
2011-05-18 09:24
169 查看
调试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;width: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>
<!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;width: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>
相关文章推荐
- 一个图片轮换显示的实现,使用DIV+JS,支持Firefox,IE,Safiri
- 有关打印、收藏等的JS代码(打印等主要使用了一个IE组件来实现)
- IE下使用js调用系统activex实现文件下载
- 一个图片轮换显示的实现,使用DIV+JS,支持Firefox,IE,Safiri
- 有关打印、收藏等的JS代码(打印等主要使用了一个IE组件来实现)
- JavaScript:使用js实现发送邮箱验证码,按钮倒计时
- 原创:微信小程序+WEB使用JS实现注册【60s】倒计时功能
- 使用Node.js+Socket.IO搭建WebSocket 实现多人群聊
- node.js中的console.trace方法使用说明
- 使用js中常用的鼠标事件实现一个拖拽的例子
- js实现60秒倒计时效果(使用了jQuery)
- Zero Clipboard js+swf实现的复制功能使用方法
- [iOS] 使用WebViewJavascriptBridge实现OC与JS交互
- vue.js使用v-model指令实现的数据双向绑定功能示例
- 使用js实现图片切换
- 使用ajaxFileUpload.js插件实现ajax无刷新上传文件
- 原生js实现下拉级联操作+通过disabled对下拉框不使用
- node.js中的console.time方法使用说明
- node.js中的console.timeEnd方法使用说明
- 使用nodejs+express(4.x+)实现文件上传