SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    bdg
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't access iframe

    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="http://cdn-images.mailchimp.com/embedcode/slim-081011.css" 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="http://seocomrade.us2.list-manage.com/subscribe/post?u=708dca3d5b07fe3c83daf6c8e&amp;id=f927596ad1" 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-->

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    265
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hy,
    Try this code:
    Code:
    <script language="javascript">
    function mailChimp() {
     var daftar = document.getElementById('iframe_id');
      alert(daftar.contentWindow.document.getElementById('mce-EMAIL').value);
    }
    </script>
    Replace "iframe_id" with the id of your iframe.
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    bdg
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Marplo .... you are the man!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •