Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error with Javascript in Firefox - works in IE

Posted on 2008-10-09
7
Medium Priority
?
211 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 43

Accepted Solution

by:
David S. earned 500 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 500 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
[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

 

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 43

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Bada platform is becoming more and more famous this days and people talking about same. Some friends included those who have bada OS mobile asked me "what is bada?"and "what its features?". That encouraged me to research and write this article. [st…
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 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