Best practices to Write JavaScript for Project Online (Part 3)

Posted By Posted by: EPM Partners on June 8, 2017

Create dummy console object to avoid script error in Internet Explorer

One common issue I face, with Internet Explorer version 11 and below, is that if my code uses console object for diagnostics, it blocks the execution of the rest of the script.

Interestingly, if I open a debug console (by pressing F12 or right click -> Inspect element), the script executes just fine without any error message. After some research in Google, it turned out that IE does not have a console object defined if a console window is not already open. See this stack overflow question for details:

To avoid this error, simply add the below lines at the start of your JavaScript code. This will create a dummy console object if the real console object doesn’t exist already.


Blog Posted In Blog Posted In: Blog, How to, Project Online
Blog Posted In 

Leave a Reply

Your email address will not be published.