Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help - Unable to Access Iframe value in firefox

Status
Not open for further replies.

cowcool

Technical User
Apr 16, 2003
8
ID
Hi Guys:),

I have a javascript code that tries to access form value in an IFRAME

the following code works perefectly in both IE and OPERA but FireFox always give me this error message:

"window.daftar.formku is undefined"

I have also tried

alert(window.frames[1].formku.email.value);

but it doesn't work too

I always get ""window.daftar.formku is undefined"

Where did I make mistake? Thanks :)


Code In Parent Frame
====================


<script language="javascript">
function mailChimp() {


alert(window.daftar.formku.email.value);
}

</script>



Code In the IFrame , iframe name="daftar"
==========================================

<!-- Begin MailChimp Signup Form -->
<link href=" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
<!-- Add your own MailChimp form style overrides in your site stylesheet or in here. -->
</style>
<div id="mc_embed_signup">
<form action=" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
<label for="mce-EMAIL">Subscribe to our mailing list</label>
<input type="email" value="myworld@myworld.com" name="email" class="email" id="mce-EMAIL" placeholder="email address" required>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</form>
</div>

<!--End mc_embed_signup-->
 
Hi

You can not refer an [tt]iframe[/tt] by [tt]name[/tt] like that. It works in Explorer because they promote sloppy coding style. And works in Opera because your document is probably rendered in quirks mode. In quirks mode the browsers are trying their best to solve erroneous code, but there is no guarantee the result will be the expected one. So better do not rely on quirks and write your documents, styles and scripts according to the standards.

Try a reference like [tt]window.frames.daftar.document.forms.formku.email.value[/tt] or [tt]window.frames['daftar'].document.forms['formku'].elements['email'].value[/tt].


Feherke.
 
Thanks man,


I tried window.frames.daftar.document.forms.formku.email.value and window.frames['daftar'].document.forms['formku'].elements['email'].value


but I still get the same error message

"window.frames.daftar.document.forms.formku is undefined
Berkas Kode Sumber:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top