/ Published in: JavaScript

This will detect if console.log is available in browser and display the message. Otherwise will display as alert message
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Can use empty catch {} if don't want inadvertent alert message to be seen on production site function trace(s) { try { console.log(s) } catch (e) { alert(s) } }; //Can use empty catch {} if don't want inadvertent alert message to be seen on production site function trace(s) { try { console.log(s) } catch (e) {} };
Comments
