Hi, I'm using NiceMenus in Drupal 6.2 which works fine in Firefox, but errors out in IE v7.0.6000.16643. When a flyout is activated IE throws the following error message:

A Runtime Error has occured.
Do you wish to debug?
Line: 7
Error: Object doesn't support this property or method.
[Yes][No]

Click the No button and a second error message pops up, identical to the first except the error is on Line 9.
Any ideas?

CommentFileSizeAuthor
#6 nice_menus.js_.txt1.59 KBwilco67

Comments

add1sun’s picture

Status: Active » Postponed (maintainer needs more info)

I don't know enough about JS to figure out why you are getting that since no one else has reported it. Do you have any other JS running on the page (other than drupal.js)?

jwcdyntek’s picture

Hi, I am also using NiceMenus in Drupal 6.2 and it works fine in firefox, shows up in IE 7.0.5 , but has errors that Object doesnt support this property or method line 10 and the submenus do not show up at all in IE 6.0.29 but has the same errors as in IE 7.05. I am pretty sure it has to do hovering over the menu items.

cosmicdreams’s picture

I am experiencing this same problem. I have:

Drupal 6.2
Nice Menus 6.x 1.1
IE 7.0.5730.11
FF 2.0.0.14

I get the same error as listed above. And thought it might be related to the variable naming issue listed here

cosmicdreams’s picture

Script Debugger says that the error is on this line:

nice_menus.js : line 7
$(this).addClass("over").find("> ul").show().addShim();

The full function is this:

// We only do the javascript in IE thanks to drupal_set_html_head in .module.
if (document.all) {
  function IEHoverPseudo() {
      $("ul.nice-menu li.menuparent").hover(function(){
          $(this).addClass("over").find("> ul").show().addShim();
        },function(){
          $(this).removeClass("over").find("> ul").removeShim().hide();
        }
      );
      // Add a hover class to all li for CSS styling. Silly naming is done
      // so we don't break CSS compatibility for .over class already in use
      // and due to the fact that IE6 doesn't understand multiple selectors.
      $("ul.nice-menu li").hover(function(){
          $(this).addClass("ie-over");
        },function(){
          $(this).removeClass("ie-over");
        }
      );
    }

    // This is the jquery method of adding a function
    // to the BODY onload event.  (See jquery.com)
    $(document).ready(function(){ IEHoverPseudo() });
}
cosmicdreams’s picture

I figured out that it was the addShim() on lines 7 and 8 that caused the bug. However, removing those functions did not allow the drop downs to appear properly.

It could be a weird layout issue with IE here. When I gave the menuparent's ul a left and top of 0 it the first item appeared over the anchor that I hovered. Doing that showed me that nearly everything had a higher z-index. Perhaps there is a z-index: -1 applied somewhere?

wilco67’s picture

StatusFileSize
new1.59 KB

I have had the same issue, and worked something out. to me it looks like that the function is not a valid call for IE.
the function itself needs to be defined still, it is called from other places.

this is the new function definition and it works fine for me now. also for IE and firefox, no issues with display or behaviour anymore. ( attached i have the new nice_menus.js file; just handy for some. just remove the _.txt extention )

---------------------

if (document.all) {
function IEHoverPseudo() {
// $("ul.nice-menu li.menuparent").hover(function(){
// $(this).addClass("over").find("> ul").show().addShim();
// },function(){
// $(this).removeClass("over").find("> ul").removeShim().hide();
// }
// );
// Add a hover class to all li for CSS styling. Silly naming is done
// so we don't break CSS compatibility for .over class already in use
// and due to the fact that IE6 doesn't understand multiple selectors.
$("ul.nice-menu li").hover(function(){
$(this).addClass("ie-over");
},function(){
$(this).removeClass("ie-over");
}
);
}

// This is the jquery method of adding a function
// to the BODY onload event. (See jquery.com)
$(document).ready(function(){ IEHoverPseudo() });
}

vanauslo’s picture

Version: 6.x-1.1 » 5.x-1.2

All right it works properly now in IE 7 in Windows XP with Drupal 5.

cosmicdreams’s picture

I agree wilco: I was also able to decipher that addShim() and removeShim() were the culprits in producing this error for me. Instead of doing the alteration you've written, I just removed those two functions from the js file and was able to proceed.

add1sun’s picture

Status: Postponed (maintainer needs more info) » Active

Hrm, well this is sucky that the shim is causing issues all of the sudden since it has been happily working for quite a while. The shim is needed in IE6 so that the menus will work properly over form selects so hopefully someone with JS know-how can figure out how to fix it vs. getting rid of it.

cosmicdreams’s picture

@ add1sun: Also of importance is why this error occurs within this theme and not in other themes (garland). Could it be related to the duplicative variable naming issue I linked above?

add1sun’s picture

Hrm, well there are no HTML form IDs of addShim or removeShim that I'm aware of so that doesn't seem quite right.

dinaiz’s picture

The easiest way (which works) to fix the issue is ...to ignore it ! I added a try-catch block around the guilty lines, with an empty catch, and everything works, except the highlighting, but this is not that important, at least for me.

Here's the code :

$("ul.nice-menu li.menuparent").hover(function(){
          try {$(this).addClass("over").find("> ul").show()();}
		  catch(e){}
        },function(){
          try {$(this).removeClass("over").find("> ul").hide();}
		  catch(e){}
        }
     );
add1sun’s picture

There is now an issue to remove the JS from IE 7 altogether (#269857: Remove JS from IE 7) but I need testers for some related issues in order to do that:

#136702: Disappearing links in IE 7.0
#235562: jQuery gets reloaded by drupal_add_js

add1sun’s picture

Status: Active » Postponed (maintainer needs more info)

All of the patches from the above issues have been added to the dev versions (for 5 and 6). Please test these new devs to see if that fixes the problem. They basically fixed the CSS issue and removed JS from IE 7.

add1sun’s picture

Status: Postponed (maintainer needs more info) » Fixed

Closing this as fixed since no reports back.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

jreashor’s picture

This error is still present in IE6. The addShim and removeShim methods are declared outside of the document.ready function, making them out of scope. The code should be updated as such:

// $Id: nice_menus.js,v 1.5.2.10 2008/08/04 23:46:09 add1sun Exp $

// We need to do some browser sniffing to weed out IE 6 only
// because only IE6 needs this hover hack.
if (document.all && !window.opera && (navigator.appVersion.search("MSIE 6.0") != -1) && $.browser.msie) {

$(document).ready(function(){
$("ul.nice-menu li.menuparent").hover(function(){
$(this).addClass("over").find("> ul").show().addShim();
},function(){
$(this).removeClass("over").find("> ul").removeShim().hide();
}
);

$.fn.addShim = function() {
return this.each(function(){
if(document.all && $("select").size() > 0) {
var ifShim = document.createElement('iframe');
ifShim.src = "javascript:false";
ifShim.style.width=$(this).width()+1+"px";
ifShim.style.height=$(this).find("> li").size()*23+20+"px";
ifShim.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";
ifShim.style.zIndex="0";
$(this).prepend(ifShim);
$(this).css("zIndex","99");
}
});
};

$.fn.removeShim = function() {
return this.each(function(){
if (document.all) $("iframe", this).remove();
});
};
});
}