getElementById click in firefox not working

I need to see why the getElementById().click() doesnt work in Firefox? It works ok in IE6 but not FF. I've herd that the click() event is not supported by FF. Is there any way to fix it?

Here is my code:
onMouseOver="parent.Switch.document.getElementById('DownON').click()"

There is an iframe on the page called "Switch". inside that it loads a html file with a 2 buttons with an id of "DownON" and "DownOFF". Once that button is clicked it moves some text down. Works fine like i said in IE but not FF.

The JavaScript console in Firefox tells me after rolling over the image with my mouse:
"parent.Switch has no properties"

The iframe code is this:
<iframe id="Switch" src="MiddlePage.html" width=615 height=337 marginwidth=0 marginheight=0 frameborder=0 scrolling=no></iframe>

The MiddlePage buttion code is this:
<input type="button" id="downON" name="downON" onclick="scroll(-4)" /><input type="button" id="DownOFF" name="DownOFF" onclick="noScroll()" />

David
StealthrtAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale BurrellDirectorCommented:
Unless I am mistaken all your code is within the IFRAME - therefore you shouldn't need to reference the parent?

onMouseOver="document.getElementById('DownON').click();"
should work quite happily I would have thought?
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try like:

onMouseOver="window.parent.frames[0].document.getElementById('downON').click()"


also, Javascript is case-sensitive, it should be as "downON", NOT "DownON"..
0
StealthrtAuthor Commented:
Thanks for the fast replys guys.

I have tryed the changing the code to:
document.getElementById('DownON').click();

But it still does nothing. Gives me the error:
document.getElementById("DownON") has no properties

Ryancys: Thats the ID's name just as it appears on the button itself. Like i said, it works fine in IE so the code works, it just seems to have trouble in FF.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

StealthrtAuthor Commented:
And to correct something that dale_burrell said:
The onMouseOver="parent.Switch.document.getElementById('DownON').click()" is OUTSIDE of the iframe. It controls the 2 buttions within the iframe.

David
0
Dale BurrellDirectorCommented:
I wouldn't assume anything from the fact that it works in IE :)

The document is accessed different in IE & Firefox... here is some code that should work in both:

var MyIframe = document.getElementById("Switch");
var oDoc = (MyIframe.contentWindow || MyIframe.contentDocument); // Handle IE & Firefox
if (oDoc.document)
{
    oDoc = oDoc.document; // oDoc is now IFRAME Document
    oDoc.getElementById('DownON').click()";
}

HTH
0
StealthrtAuthor Commented:
Thanks Dale: One quesiton, how would i set that code off that u posted useing the:
onMouseOver="" command?

David
0
Dale BurrellDirectorCommented:
onMouseOver="var MyIframe = document.getElementById("Switch");var oDoc = (MyIframe.contentWindow || MyIframe.contentDocument);if (oDoc.document) {oDoc = oDoc.document;oDoc.getElementById('DownON').click()";}"
0
StealthrtAuthor Commented:
Ok this is how i set it up:

<script type="text/JavaScript">
function clickButtion(){
var MyIframe = document.getElementById("Switch");
var oDoc = (MyIframe.contentWindow || MyIframe.contentDocument); // Handle IE & Firefox
if (oDoc.document)
{
    oDoc = oDoc.document; // oDoc is now IFRAME Document
    oDoc.getElementById('DownON').click();
}
}
</script>

Two problems:
1) Still does not work :o(     ERROR: oDoc.getElecmentById("DownON") has no properties.
2) I need the "DownOFF" as well when the onMouseOut. Im sure i could make another function but it would be nice to have it in one thing.
0
Dale BurrellDirectorCommented:
What a coincidence but I've just run into the same problem in some code I'm writing - it seems that Firefox doesn't realide the object in question supports the click() function... working on it - will let you know if I solve it.
0
StealthrtAuthor Commented:
Ok. Yes, please let me know! :o)

David
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>Thats the ID's name just as it appears on the button itself. Like i said, it works fine in IE so the code works, it just seems to have trouble in FF.

That's why i mentioned Javascript is case-sensitive... In IE there is less restriction on what you coding in javascript, that's why it's still working...

I tested the line:

onMouseOver="window.parent.frames[0].document.getElementById('downON').click()"

and it works in FF (2.0) before I posted here.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale BurrellDirectorCommented:
Actually what you've done should work - are you sure you've got the case correct? Try oDoc.getElementById('downON').click(); just to check? If that still doesn't work try this instead of oDoc.getElementById('DownON').click(); have alert(oDoc.getElementById('DownON').tagName);
0
Dale BurrellDirectorCommented:
Yes - I think ryancys is correct - my problem is that I am trying to click a link (<a>) and it doesn't seem possible in Forefox!
0
StealthrtAuthor Commented:
Well well... the best thing that i love about programming comes out everytime... case sensitive.

Thanks ryancys, looks like you were correct.

David
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Components

From novice to tech pro — start learning today.