Solved

Error with Javascript in Firefox - works in IE

Posted on 2008-10-09
7
203 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

I spend far too much time on the web keeping up with the news: politics, the environment, computer stuff, the Experts Exchange. It's never-ending. But many of the most informative web pages are overwhelmed with noise: scrolling banners, flashing tex…
It's here again; Microsoft is launching a new version of Internet Explorer: Internet Explorer 9, with noticeable changes on its interface, functions and new tools. As they say on its promotional video: "It's time to play, on a more beautiful web", f…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
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…

808 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