Solved

Error with Java Script in IE 8

Posted on 2009-04-02
4
3,916 Views
Last Modified: 2013-11-23
IE 8 has broken our online programs.  I work for a small insurance company.  Our agents do there quotes online, and with IE 8 I started getting calls that they couldn't do any quotes.  I told them that we haven't had the time yet to take a look at IE 8 and to roll back to IE 7 for now.  The problem is in our drop down menus.  It is a simple mouse over menu that drops down sub menus.  What is happening is when you mouse over one of the sub menus it hilights the proper color but when you move on to the sub menu below that one it stays blue and gives us an error of "Invalid Argument" in our menu.js.  Line number is 446 and character 9.  A snippet of the code is included.  The menu.js program wasn't written by us, and from what I have been told it hasn't been modified.  Although that might not be correct.  There is also no one in our office that has a really good understanding of java script.  We have just picked up piece here and there as we needed to.  I've marked the line that IE 8 is telling us has the "Invalid Argument".
if (l.hilite) {

            l.document.bgColor = l.menuHiliteBgColor;

            l.zIndex = 1;

            l.hilite.visibility = "inherit";

            l.hilite.zIndex = 2;

            l.document.layers[1].zIndex = 1;

            l.focusItem.zIndex = this.zIndex +2;

        }

        l.focusItem.top = this.top;

        l.Menu.hideChildMenu(l);

    } else if (document.all && l.style && l.Menu) {

        document.onmousedown=l.Menu.onMenuItemDown;

        if (a) {

            a.style.backgroundColor = a.saveColor;

            if (a.hilite) a.hilite.style.visibility = "hidden";

        } else {

            a = new Object();

		}

        if (l.mouseover && l.id != a.id) {

            if (l.mouseover.length > 4) {

                var ext = l.mouseover.substring(l.mouseover.length-4);

                if (ext == ".gif" || ext == ".jpg") {

                    l.document.images[l.id + "Img"].src = l.mouseover;

                } else {

                    eval("" + l.mouseover);

                }

            }

        }

		if (l.isSeparator) return;

        l.style.backgroundColor = l.menuHiliteBgColor;

        if (l.hilite) {

            l.style.backgroundColor = l.menuHiliteBgColor;

            l.hilite.style.visibility = "inherit";

        }

        l.focusItem.style.pixelTop = l.style.pixelTop;

        l.focusItem.style.zIndex = l.zIndex +1;           <------Error Line

        l.zIndex = 1;

        l.Menu.hideChildMenu(l);

    } else if (document.getElementById){

        document.onmousedown=l.Menu.onMenuItemDown;	

        if (a) {

	        a.style.backgroundColor = a.saveColor;

    	    if (a.hilite) a.hilite.style.visibility = "hidden";

        } else {

            a = new Object();

        }

        if (this.mouseover && this.id != a.id) {

            if (this.mouseover.length > 4) {

                var ext = this.mouseover.substring(this.mouseover.length-4);

                if (ext == ".gif" || ext == ".jpg") {

                    document.images[l.id + "Img"].src = this.mouseover;

                } else {

                    eval("" + this.mouseover);

                }

            }

        }

Open in new window

0
Comment
Question by:jeffr1970
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
Thomas4019 earned 500 total points
ID: 24054408
I think you call " l.zIndex " should be " l.style.zIndex " on the error line
0
 

Author Comment

by:jeffr1970
ID: 24054962
That fixed that problem.  What we don't understand though, is why did something that simple break our programs in IE 8 but since around IE 3 or 4 it has worked without any issues.  Is this something that probably shouldn't of worked all these years?  

0
 
LVL 3

Expert Comment

by:avdej
ID: 24073342
I'm afraid the previous solution may be unsafe and may (under certain conditions) destroy some sensible logic behind the menu behavior.

Object 'l' seems to be a global data holder and 'l.zIndex' seems to be a 'reference' zIndex value that will be used to properly place the element currently focused.

The cause of the problem is that at a very first call of that method l.zIndex has an 'undefined' value (some 'init.js' file missing?), which added to 1 evaluates to NaN. Probably IE 8 does not want to accept that NaN value as a valid zIndex value anymore.

In my opinion, the better solution would be to place JUST BEFORE that error line the following harmless line of code:

l.zIndex = l.zIndex == null ? 1 : l.zIndex;

It will fix the problem as well AND will not affect the following menu behavior.

Dear, jeffr1970, please NOTE
IF you accept a solution and write in your comment: "That fixed that problem..."
THEN it is time to close the question, to select one or more answers that helped AND to provide a grade.

Regards,
Avdej
0
 

Author Comment

by:jeffr1970
ID: 24110795
Let me try that out and I'll close this out tomorrow.  I apologize for the delay, I had a personal issue come up and I'm just now getting back to work.  Where as putting "l.style.zindex" worked, I was hoping for some type of reasoning on why it has worked with every version of IE until IE 8.  That is why I asked ANOTHER question in my response.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now