Return to Snippet

Revision: 48219
at June 26, 2011 16:24 by anagaiyahoocom


Updated Code
//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) {}
};

Revision: 48218
at June 26, 2011 16:16 by anagaiyahoocom


Initial Code
//Can use empty catch {} if don't want inadvertent alert message to be seen on production site 

function trace(s) {
  try { cosdsnsole.losg(s) } catch (e) { alert(s) }
};

Initial URL

                                

Initial Description
This will detect if console.log is available in browser and display the message. Otherwise will display as alert message

Initial Title
Preventing javascript error using console.log on old browsers

Initial Tags
javascript

Initial Language
JavaScript