0

I need help with one error I have with Plugin Block.

I have two editors with Aloha, I define in the first editor, one Block(span),and finally I want drag/drop this block to the second editor, I can do it but after I have this error in IE8:

JScript: 'Console' is undefined

and the behaviour of the editor is strange.

I'm trying to find a solution for this in Google, but I've had no luck.

Aloha.jQuery('.variable').alohaBlock();

Can somebody help me please?

CBRRacer
  • 4,451
  • 1
  • 21
  • 27
reizintolo
  • 379
  • 1
  • 5
  • 20

2 Answers2

0

The console object is not available in older browsers. This plugin probably uses either console.log() or console.error() somewhere in the code for debugging purposes.

You could make an empty implementation of those to make sure it doesn't break when in an older browser:

if (!console)
{
    console.log = function(){};
    console.error = function(){};
}
user887675
  • 537
  • 2
  • 6
0

You can try to define the console function so it will not error out because of the console not being available. But because it's trying to write to the console, I'm assuming there may be an error which it's trying to tell you about.

Taken from HTML5 Boilerplate. Just place this self executing function before you add Aloha(preferably before you add any javascript at all, this should be first).

// Avoid `console` errors in browsers that lack a console.
(function() {
    var method;
    var noop = function () {};
    var methods = [
        'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
        'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
        'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
        'timeStamp', 'trace', 'warn'
    ];
    var length = methods.length;
    var console = (window.console = window.console || {});

    while (length--) {
        method = methods[length];

        // Only stub undefined methods.
        if (!console[method]) {
            console[method] = noop;
        }
    }
}());
Adam Merrifield
  • 9,819
  • 4
  • 37
  • 54