www.webdeveloper.com
Results 1 to 3 of 3

Thread: Click button from iFrame in Parent Window?

Hybrid View

  1. #1
    Join Date
    Apr 2014
    Posts
    13

    Click button from iFrame in Parent Window?

    Hello All,

    I am currently trying to amend our IT Support System to make it nice and simple for our end users (hospital users who are not good with computers) and need a way to click the 'Save' button from an iFrame. Inspecting the element i see the below code on the button i would link to click with code:

    Code:
    <input type="button" class="pushButton" id="mainForm-ApplyButton" value="Save" onclick="$C('mainForm').apply();" style="width: 121px;">
    I can embed an iFrame on the page without invalidating our support agreement but cant edit the main page hence the reason for this question.

    Does anyone have any ideas? Much appreciated and happy Easter!
    Dan

  2. #2
    Join Date
    Mar 2005
    Location
    Behind you...
    Posts
    899
    So you want to click (or simulate a click rather) that button, which is on the 'main' page, from inside of an iframe on the same page?

    As long as the main page and iframe are on the same domain (and I assume they are for this case), you should be able to do that like this:
    Code:
    parent.document.getElementById("mainForm-ApplyButton").click();
    Though, to be fair you could also just call the function that gets executed by that button directly instead. I may be wrong but I believe it would work something like this:
    Code:
    parent.$C("mainForm").apply();
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  3. #3
    Join Date
    Apr 2014
    Posts
    13
    Thank you that works a treat! I did Google it but this seems like a minefield and i did not understand until your code on my other post on how to put this together!

    Last question, how would i save the form (clicking the button) and then once the page has refreshed then click a second button (This will be a save and the press submit routine).

    Thanks Sup3rkirby!

    -Dan

    Quote Originally Posted by Sup3rkirby View Post
    So you want to click (or simulate a click rather) that button, which is on the 'main' page, from inside of an iframe on the same page?

    As long as the main page and iframe are on the same domain (and I assume they are for this case), you should be able to do that like this:
    Code:
    parent.document.getElementById("mainForm-ApplyButton").click();
    Though, to be fair you could also just call the function that gets executed by that button directly instead. I may be wrong but I believe it would work something like this:
    Code:
    parent.$C("mainForm").apply();

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles