IE8 console未定义
来源:互联网 发布:藏宝阁交易数据异常 编辑:程序博客网 时间:2024/05/01 06:56
写了一个extjs页面,在chrome下调试好好的,在ie8下调试页面打开,进度条没按预期更新。代码如下:
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title>ExtJs</title><meta charset="GBK"><link href="ExtJs/resources/css/ext-all.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="ExtJs/ext-base.js"></script><script type="text/javascript" src="ExtJs/ext-all-debug-w-comments.js"></script> </head><body> <div> <script type="text/javascript">Ext.MessageBox.show({ title: '倒计时提醒', <span style="white-space:pre"></span> msg: '这是一个倒计时', buttons:{"ok":"知道了"}, animEl: 'mb9', closable : false, width : 300, progress : true, progressText: '5秒后将xxx', fn: answerPhone});var timeLeft = 5; var countDownTask = {run:countDownFunc,interval:1000}; function countDownFunc(){ console.log("fuck" + timeLeft); if(timeLeft <= 0){ Ext.MessageBox.updateProgress(1, "倒计时结束");Ext.MessageBox.buttons = false;//简单延迟后关闭窗口setTimeout(function(){Ext.MessageBox.hide()}, 500);//终止轮询任务Ext.TaskMgr.stop(countDownTask);answerPhone();}else{ timeLeft--; Ext.MessageBox.updateProgress((5-timeLeft)/5, timeLeft+'秒之后将xxxx');}}Ext.TaskMgr.start(countDownTask);var answerPhone = function(){ console.log("倒计时后调用的函数。");}; </script> </div></body></html>
按F12查看控制台信息,发现这么一句"console未定义"。网上查了一下,有两种解决办法
1.注释掉console的语句(好暴力....)
2.但是有时候实在是需要支持console来调试,那么可以加入如下代码
window.console = window.console || (function(){ var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function(){}; return c; })();
加入上述片段后,ie8就可以使用console了,修改后的代码
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title>ExtJs</title><meta charset="GBK"><link href="ExtJs/resources/css/ext-all.css" rel="stylesheet" type="text/css" /><script type="text/javascript" src="ExtJs/ext-base.js"></script><script type="text/javascript" src="ExtJs/ext-all-debug-w-comments.js"></script> </head><body> <div> <script type="text/javascript">window.console = window.console || (function(){ var c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile = c.clear = c.exception = c.trace = c.assert = function(){}; return c; })();Ext.MessageBox.show({ title: '倒计时提醒', msg: '这是一个倒计时', buttons:{"ok":"知道了"}, animEl: 'mb9', closable : false, width : 300, progress : true, progressText: '5秒后将xxx', fn: answerPhone});var timeLeft = 5; var countDownTask = {run:countDownFunc,interval:1000}; function countDownFunc(){ console.log("fuck" + timeLeft); if(timeLeft <= 0){ Ext.MessageBox.updateProgress(1, "倒计时结束");Ext.MessageBox.buttons = false;//简单延迟后关闭窗口setTimeout(function(){Ext.MessageBox.hide()}, 500);//终止轮询任务Ext.TaskMgr.stop(countDownTask);answerPhone();}else{ timeLeft--; Ext.MessageBox.updateProgress((5-timeLeft)/5, timeLeft+'秒之后将xxxx');}}Ext.TaskMgr.start(countDownTask);var answerPhone = function(){ console.log("倒计时后调用的函数。");}; </script> </div></body></html>
0 0
- IE8 console未定义
- IE8下提示'console'未定义错误
- console.log在IE8中未定义
- IE8下提示’console’未定义错误
- 关于 IE8 console不未定义的问题
- IE8/IE9出现「‘console’未定义」错误
- ie console 未定义
- ie9 提示'console' 未定义
- IE8下console undefined
- 让IE8兼容console
- 可恶的ie8 id未定义
- ie9 提示'console' 未定义问题的解决方法
- ie9 提示'console' 未定义问题的解决方法
- IE8 下console报错问题
- IE8/IE9 console 应该注意的问题;
- ie8不支持console.log()的解决方法
- 使用Firebug的console导致IE提示对象未定义错误
- IE浏览器访问工程时报错:“'console'未定义”
- 平衡二叉树(AVLs)
- Flume官方文档翻译之(五)
- DBCP、C3P0、Proxool 、 BoneCP开源连接池的比较
- [李景山php]每天laravel-20161102|CompileEngine.php-1
- NoSQL定义及分类
- IE8 console未定义
- LeetCode292. Nim Game
- JSP图片验证码
- 图像处理理论(三)——双边滤波, Steerable滤波, Gabor滤波, Schmid滤波
- Mysql与其他数据库的简单比较
- UVA11292
- web dynpro配置注意事项
- 99%的人都理解错了HTTP中GET与POST的区别
- 构建新的 App 和 App 更新时,必须使用公共(GM)版 Xcode 6 或更高版本、OS X 以及 iOS SDK。请勿提交使用 Beta 版软件,包括 Beta 版 OS X 构建的 App。