Solved

Error with Javascript in Firefox - works in IE

Posted on 2008-10-09
7
204 Views
Last Modified: 2013-12-07
I have the dubious honor of testing our apps in Firefox.  These were originally developed for IE and Netscape.  I've come across a page that has a Javascript error in Firefox, but works fine in IE.

Firefox does not like this bit of code which appears within script tags:

window.top.AdmMenu.frmMenu.action="../Gateway/TopMenu.aspxSI=FI";window.top.AdmMenu.frmMenu.submit();

I get this error: window.top.AdmMenu.frmMenu is undefined

AdmMenu is a frame within the top level frameset and frmMenu is a form on the AdmMenu page.  First and foremost is the syntax correct?  Is using window.top.frame.form the proper way to reach the form?

Am I missing something else?  Again, this works fine in IE and Netscape.  

Thanks!
0
Comment
Question by:djames44
  • 4
  • 2
7 Comments
 
LVL 42

Accepted Solution

by:
David S. earned 125 total points
ID: 22684703
Which versions of Netscape are you testing in? The ancient 4.x? 7.2? The abominations of 8+?

Try this:

window.top.frames.AdmMenu.document.forms.frmMenu.action
0
 
LVL 27

Assisted Solution

by:BigRat
BigRat earned 125 total points
ID: 22685587
You might find that you must use the full document model, in which case the frame has a collection called forms and one must index that by name.

We do something similar, but have reduced all these sorts of accesses to getElementById().
0
 

Author Comment

by:djames44
ID: 22686953
Thank you Kravimir and BigRat!  I will try both solutions today and will let you know how it goes.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:djames44
ID: 22687772
Kravimir your method worked just fine.  BigRat, I'm betting your method is the better of the two, but I need to learn more about how to use it before I can try to implement it.  Although your solution is probably best, I need to award the points to Kravimir because he chimed in first and what he suggested worked.

Thank you to both of your for responding!
0
 

Author Comment

by:djames44
ID: 22687779
Okay, I see I can split the points.  I will do that!
0
 

Author Closing Comment

by:djames44
ID: 31504872
Thank you!
0
 
LVL 42

Expert Comment

by:David S.
ID: 22687856
You're welcome.

The way I suggested is the "old" way to do it. I picked it because it was closest to what you had already and in this case there doesn't seem to be a benefit to using a "newer" way.

These should work as well: (I'm assuming 'frmMenu' is the name of the form)

top.frames.AdmMenu.document.getElementsByName('frmMenu')[0].action="../Gateway/TopMenu.aspxSI=FI";

top.frames.AdmMenu.document.getElementsByName('frmMenu')[0].setAttribute('action', "../Gateway/TopMenu.aspxSI=FI");

However, if 'frmMenu' is the ID of the form instead, you could use these:

top.frames.AdmMenu.document.getElementById('frmMenu').action="../Gateway/TopMenu.aspxSI=FI";

top.frames.AdmMenu.document.getElementById('frmMenu').setAttribute('action', "../Gateway/TopMenu.aspxSI=FI");
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Now-a-days, indirectly, postal services have been replaced by email services. Yes, whenever we hear the word "email" a lot of people only think of gmail. Some people still think that email and gmail are one and the same thing :-). Let's see some …
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

861 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