Solved

Error with Javascript in Firefox - works in IE

Posted on 2008-10-09
7
196 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

707 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

12 Experts available now in Live!

Get 1:1 Help Now