Javascript and Mozilla

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Javascript and Mozilla

Post by s.dot »

This doesn't seem to work in mozilla firefox, but it does in IE.

All it's supposed to do is call a function called resetForm() on the main page which clears a form field and gives it focus. (the page this code is contained on is within an IFRAME)

Code: Select all

<script type=&quote;text/javascript&quote;><!--
      if(parent.resetForm)
        parent.resetForm();
      //-->
    </script>
I even tried just a simple

Code: Select all

<script type=&quote;text/javascript&quote;><!--
parent.resetForm();
//-->
</script>
How do I call the function resetForm(); in mozilla?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

okay, so the problem may not lie in parent.resetForm(); but in the actual function itself.

Does Mozilla support document.getElementById("id").value=""; ?

I'm guessing it's an IE DOM feature that mozilla's decided against using.

How else would I do this javascript in Mozilla?

Code: Select all

function resetForm(){
    document.getElementById(&quote;message&quote;).value = &quote;&quote;;
    document.getElementById(&quote;message&quote;).focus();
  }
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

scrotaye wrote:Does Mozilla support document.getElementById("id").value=""; ?
It's a standard DOM feature which is (or at least should be) supported by all browsers.

Do you just want to reset the value of a form? Is this on a button press or something?

The function itself is done correctly... but not sure exactly the scenario you're calling it in.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

you might want to try parent.document.resetForm();
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

phpScott wrote:you might want to try parent.document.resetForm();
OMG... did I just do that? :P
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

wha , huh?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

d11wtq wrote:
The function itself is done correctly... but not sure exactly the scenario you're calling it in.
Alright, there's the main page, which contains a text entry field. This page also contains the resetForm(); function.

Code: Select all

function resetForm(){
     document.getElementById(&quote;message&quote;).value = &quote;&quote;;
     document.getElementById(&quote;message&quote;).focus();
}
Then, upon submission of this form, it is passed to a frame, which then clears the form on the main page, and processes the input.
The code on this page is

Code: Select all

<script type=&quote;text/javascript&quote;><!-- 
  if(parent.resetForm)
  parent.resetForm();
//-->
</script>
And parent.document.resetForm(); does not appear to work :(
Post Reply