Solved

Error with Javascript in Firefox - works in IE

Posted on 2008-10-09
7
207 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
[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
  • 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
Increase your protection from Zero Day threats!

Running two Antivirus' is never a good idea.
Taking advantage of Multiple Security layers on the other hand can often save your hide.
See which top notch security software brands have been proven to happily coexist together.
Reduce your chances of becoming a statistic.

 

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

Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

Question has a verified solution.

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

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…
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
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.
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 +…

710 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