The following JavaScript works correctly in all browsers except IE 7 and 8:
if (typeof django != 'undefined') {
console.log('Django admin loaded');
var jQuery = django.jQuery;
}
This code is on top of a JavaScript file that is loaded both inside Django's admin interface and on our public pages. Django's admin loads its own jQuery, so we use that one preferably ...
However, IE 7 and 8 executes the variable assignment inside this if statement even if the condition (typeof django != 'undefined')
is false
. At the same time, the console.log()
is not executed :-/ Removing the var
keyword, the same code works perfectly also in IE 7 and 8:
if (typeof django != 'undefined') {
console.log('Django admin loaded');
jQuery = django.jQuery;
}
But why? That doesn't make any sense, does it?