使用防止javascript错误控制台.log在旧浏览器上

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用防止javascript错误控制台.log在旧浏览器上相关的知识,希望对你有一定的参考价值。

This will detect if console.log is available in browser and display the message. Otherwise will display as alert message
  1. //Can use empty catch {} if don't want inadvertent alert message to be seen on production site
  2.  
  3. function trace(s) {
  4. try { console.log(s) } catch (e) { alert(s) }
  5. };
  6.  
  7.  
  8. //Can use empty catch {} if don't want inadvertent alert message to be seen on production site
  9.  
  10. function trace(s) {
  11. try { console.log(s) } catch (e) {}
  12. };

以上是关于使用防止javascript错误控制台.log在旧浏览器上的主要内容,如果未能解决你的问题,请参考以下文章

防止软件包安装在旧的 Python 版本上

避免IE中的javascript错误控制台.log

在控制台对象不存在的情况下防止错误消息

iOS UIWebView 中的 Javascript console.log()

JavaScript的执行console.log导致错误:“在主线程同步的XMLHttpRequest已经过时......”

如何在 Swift 中将 javascript console.log 到 println() 到 Xcode 调试器?