Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    55
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Question How can I click a button that on on a webpage within an iFrame?

    If I have a webpage(www.MyPage.com/main), and on that page is an iFrame that has another one of my webpages(www.MyPage.com/another) within it, and that webpage(www.MyPage.com/another) has a button that will display a popup alert, how can I create a button on the main page(www.MyPage.com/main) that will click that button one time?

    We'll say that the button on www.MyPage.com/another is within a form that is named "form1" and the button is named "submitter".

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by MrAtoBandMe View Post
    If I have a webpage(www.MyPage.com/main), and on that page is an iFrame that has another one of my webpages(www.MyPage.com/another) within it, and that webpage(www.MyPage.com/another) has a button that will display a popup alert, how can I create a button on the main page(www.MyPage.com/main) that will click that button one time?

    We'll say that the button on www.MyPage.com/another is within a form that is named "form1" and the button is named "submitter".
    I don't think that is possible for security reasons. But have a look at http://css-tricks.com/snippets/html/...-to-an-iframe/
    Last edited by Philip M; 04-01-2013 at 08:31 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    i've just tested it. you can call functions on prent from iframe, and in iframe from parent.
    as long as there's no cross-domain isse i would imagine but still.
    example with simple two buttons here: http://freedockstar.com/iframeParent.php

  • #4
    New Coder
    Join Date
    Mar 2013
    Posts
    55
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Thumbs up

    I actually found the answer to this.

    I used this line within a javascript function that was on the page that contained the iFrame...

    Code:
    document.all.myFrame.contentWindow.form1.Submit.click();
    "Submit" was the name and id of the button that was on the page within the iFrame.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by MrAtoBandMe View Post
    I actually found the answer to this.

    I used this line within a javascript function that was on the page that contained the iFrame...

    Code:
    document.all.myFrame.contentWindow.form1.Submit.click();
    "Submit" was the name and id of the button that was on the page within the iFrame.
    document.all is IE only.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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