Issues of Console.Log with Internet Explorer

Aug 15, 2015 at 10:41 PM

Recently, I ran into an issue with one of my client where my particular callback function of ajax call was not called at all. It worked absolutely fine with google chrome and it was only issue with the Internet Explorer.

I did lot of digging around the ajax calls using fiddler to see if there is problem in the ajax call or whether some JavaScript file is not loaded correctly but could not find it much on that front.

I could track the issue when we open the IE development toolbar and it used to work absolutely fine. Initially I could not produce it  on my machine as I frequently use the IE toolbar. After troubleshooting a bit i found out that console object is exposed only when the developer tools are opened for a particular tab. If I do not open the developer tools window for that tab, the console object remains exposed for each page you navigate to. If I open a new tab, I must also open the developer tools for that tab in order for the console object to be exposed.

This was some petty issue which took lot of time to identify for me. So for workaround on this I  developed a small utility file for logging into console which will work across all the browsers.
This utility will log console messages only when console object is active else it will skip logging.

 FileName : DPSUTILS.js
 Author : Dhaval Shah
 Description : This Javascript library contains common methods to do the read/Write operation across
 different data sources e.g. UserProfile, Managed Metadata Service and Search Service
 (function() {
 if (!window["DPS"]) {
 window["DPS"] = {};
 DPS.Namespace = {
 Register: function(namespace) {
 var parts,
 parts = namespace.split(".");
 partsLength = parts.length;
 context = window;
 nsPath = "";
 for (var i = 0, l = partsLength; i < l; ++i) {
 var name = parts[i];
 if (!context[name]) {
 context[name] = {};
 context[name].__namespace = name;
 nsPath += name + ".";
 context = context[name];
 if (!context.__namespace) {
 context.__namespace = nsPath.substring(0, nsPath.length - 1);
 return context;
 * This namespace contains utility functions used across application.
 (function() {
 * Logs the exception message in browser console
 * @param {string} message - Exception Message
 logAjaxErrorMessage: function(xhr, status, error) {
 if (xhr.responseText != "") {
 var message = xhr.responseText;
 if (typeof console === "undefined") {
 logMessage: function(message) {
 if (typeof console === "undefined") {

Save this file as DPSUTILS.js and reference it in your code.

In order to log message you can directly use

DPS.UTILS.logMessage("My Log Message . . .");

I hope this was helpful..

Happy Coding !

Found this article by Dhaval Shah valuable? Help by Sharing ...

  • Click on the banners at the top of article or in the right panel to visit my blog's sponsors. They are all hand-picked and are selected based on providing great products and services to the SharePoint community.
  • I’d be very grateful if you’d help it spread by Sharing. Below, you should find links to sharing this article on your favorite social media sites.
Related Posts by Dhaval Shah blog comments powered by Disqus