?
Solved

Error with Java Script in IE 8

Posted on 2009-04-02
4
Medium Priority
?
3,928 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
Thomas4019 earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 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