The Prototype javascript library is used for various purposes like in-page popup, drag-n-drop etc.

Recently while working on one of my Rails project, I came to know that there is a JavaScript NULL object error in base.js with ‘Dialog.cancelCallback()‘ function. This error cannot be seen or catch by other browsers but IE7. (Well I was using Prototype.js v1.6.0.1)

closePopup: function (){
  return false;

‘Dialog.cancelCallback()’ function used to close the in-page popup. Once you close the popup and scroll the page in IE7 it shows a javascript null object error at line number 2140 and 2083. But actually the problem is not at these lines. The problem is related and situated in ‘close’  function at line number 1350. So to fix this I added one check there for Internet Explorer and got relaxed!

close: function() {
  // Asks closeCallback if exists
  if (this.visible) {
    if (this.options.closeCallback && ! this.options.closeCallback(this))

    // to resolve IE7 JS null object error
    if (navigator.appName != 'Microsoft Internet Explorer') {
      if (this.options.destroyOnClose) {
        var destroyFunc = this.destroy.bind(this);
        if (this.options.hideEffectOptions.afterFinish) {
          var func = this.options.hideEffectOptions.afterFinish;
          this.options.hideEffectOptions.afterFinish = function() {func();destroyFunc()
      } else {
        this.options.hideEffectOptions.afterFinish = function() {destroyFunc()}


    this.doNotNotifyHide = true;
    this.doNotNotifyHide = false;

You might also like: