Skip to page content or Skip to Accesskey List.

Work

Main Page Content

Netscape Javascript Bug

Rated 3.91 (Ratings: 1)

Want more?

  • More articles in Code
 
Picture of Jeff Howden

Jeff Howden

Member info

User since: 14 Dec 1998

Articles written: 21

Just when you had your fill of bugs and workarounds to get stuff to work with both NN and IE, I recently uncovered a bug that happens in both NN3 and NN4 when using frames and image rollovers.

If you've ever read through JavaScript documentation at Netscape you may have noticed that there are some words that are reserved. Usually, when using these words your scripts will fail miserably, leaving you to figure out what the heck is going on. However, as I discovered recently, these problems can sometimes be painful to locate.

I was putting together a quick demo site for some product that my girlfriend was showcasing to some dealers in her career field; a gallery of sorts. This gallery was a lot like other galleries on the net, complete with frames, explanatory title in the top frame, content in the middle frame complete with rollovers, and previous and next buttons in the lower frame.

Since I would be using JavaScript in the lower frame along with the traditional target attribute for a normal link, I made sure I'd labeled each frame with an appropriate name. I tested this whole thing out in IE5 and was quite pleased with myself. I'd knocked out picture taking, design, layout, coding, and testing in about 2.5 hours. It was late so I put it away for the night. The next morning, however, when I had my girlfriend test it out before sending this dealer the URL, she complained that it didn't work. I cranked up Netscape immediately to find out what was wrong.

The first couple of clicks on the next button would work fine until I put my mouse on the rollover in the content frame and then no amount of clicking next or previous would take me anywhere. I also had a normal link in the bottom frame with a target value of content, that when clicked would open a new window with the document referenced in the link, instead of opening the document in the content frame. I opened up the JavaScript console to find a long list of errors, all the same.

JavaScript Error: http://000.000.000.000/bottom.html, line 43:

parent.content has no properties.

I'd encountered this once before, but I couldn't remember where or what had caused it. I couldn't remember what had caused it before because I never figured it out; until now. Using Netscape, I investigated a little bit further to find out what the problem was. I already knew that as long as I just hit the previous or next links, everything was fine. It wasn't until I initiated the rollover in the content frame that the errors started happening. It was easy to conclude that everything was fine with my previous and next functions and that the problem was elsewhere.

To begin with, I reloaded the frameset page, resetting it to the original top, middle, and bottom documents. Then, I hit CTRL+O to bring up the Open File dialogue box. I type in

JavaScript:alert(parent.frames[1].name)

(Remember, I can't use the NAME of the middle frame because it might throw errors, just like the previous and next functions were already doing, so I had to refer to the frame by it's index.) and hit OK to find out what the name of the second frame is. An alert box pops up saying content, just like I had specified in the frameset document. I click next and hit CTRL+O, the JavaScript statement I had just typed in there last time was still there so I hit OK. The alert box told me the same thing. So, I hit next again. This time, however, instead of hitting CTRL+O, I moused over the rollover in the content frame. It was time to find out what was happening. I hit CTRL+O and then OK and this time the alert box said diaspore_3. That was really odd because that was the value of the name attribute of my rollover in the content frame, not the name of the middle frame as defined in the frameset page.

I realized that something in my rollover code in the document's that were loaded into the content frame were causing this to happen. When I looked at it carefully, I found the nasty culprit immediately. I had forgotten that you cannot use reserved names as variables. I was using the variable name as one of my variables. Netscape was inadvertantly renaming the middle frame with the value of this variable. What a nightmare. I did a quick site wide search-and-replace, changing this variable's name to something else and everything was just fine.

So, let this be a lesson to all of you out there. When the documentation says not to use certain words because they're reserved, please do it or bad things will happen.

Jeff Howden (.jeff) is a web developer working for Vos & Howden, LLC in Portland, Oregon where he's partnered with long-time colleague, Anthony Vos. His skills include ColdFusion, JavaScript, CSS, XML, relational databases, and much, much more. His biggest professional accomplishments include, but are not limited to:

  • building a ColdFusion-based e-commerce solution for Mt. Bachelor that transacted over $1.62 million dollars in September 2001 with 0 (yes, that's zero) ColdFusion errors and then an almost completely rebuilt version transacted $2.86 million dollars in September 2002.
  • being asked to be a Technical Editor for the ColdFusion MX book, Inside ColdFusion MX from New Rider's Publishing company.
  • being asked by BrainBench to perform quality control on their JavaScript 1.5 certification test after receiving the highest beta test score out of 200 testees.
  • managing the server that hosts evolt.org and withstanding a slashdotting that brought over 1,000,000 hits to the site, over 10 gigs of data transfer, and an average in excess of 2300 unique visitor sessions per hour, all within a 24-hour period and the server never hiccuping once.

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.org Evolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.