Trigger a button click inside an iframe

Venelin

This is the iframe code:

<div id="OutDiv" class="outerdiv">
    <iframe src="http://beta.sportsdirect.bg/checkout/onepage/" id="InnerIframe" class="FrameCSS" scrolling="no"></iframe>
</div>

Here is the HTMl code of the button which the iframe above is calling:

<button type="button"  id="SuperWebF1" title="Continue" class="button">Continue</button>

Here is the jQuery function that i use to trigger the click of the button when page is loaded:

 $('#SuperWebF1').trigger( "click" );

But this is working like that only when i place the jQuery code inside the source of button and the iframe is calling the button with the script.

I want to make an event which is clicking the button from outside the iframe. Is it possible ?

Thanks in advance!

Amit Garg

NOTE: .contents() does not work if iframe's src points to cross domain page. More: Cross domain iframe issue and Get DOM content of cross-domain iframe

//execute code after DOM is ready
$(function() {

  //find iframe
  let iframe = $('#main_iframe');
  
  //find button inside iframe
  let button = iframe.contents().find('#main_button');
  
  //trigger button click
  button.trigger("click");
  
});
<!--Add jQuery library-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

If you need to manipulate another page inside iframe, search for official API or GET parameters. Example: Youtube Embed Video, Google Maps Embed Api

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Unable to auto click/trigger on button of iframe

From Dev

Zooming a PDF inside an iframe upon Button click

From Dev

Not able to click on a button,which is inside an iframe in chrome browser using webdriver

From Dev

I cannot click the Admin button nested inside the iFrame

From Dev

trigger AJAX action when click on button inside dropdown without closing it

From Dev

Button inside the label with the input does not trigger ng-click

From Dev

trigger AJAX action when click on button inside dropdown without closing it

From Dev

Button inside popup doesn't trigger click event outside the popup

From Dev

iFrame on button click

From Dev

Trigger storyboard on Button click?

From Dev

Button inside an iframe is not working

From Dev

button in iframe should trigger event

From Dev

JavaScript to click on a div inside iframe

From Dev

jQuery: click event inside iframe

From Dev

How to display an iframe on button click

From Dev

How to display an iframe on button click

From Dev

Click on iframe to make a button appear

From Dev

Trigger validation on click of Search button

From Dev

jQuery trigger reset button click

From Dev

Trigger button click on other element

From Dev

Not able to click a button which sites inside form which sits under Iframe which sits under table

From Dev

trigger button inside a repeater control

From Dev

jQuery trigger click event from iframe

From Dev

Trigger blur on focused element, on click outside of iFrame

From Dev

Trigger radio button click without the click

From Dev

Angular 2 trigger interpolation inside an iframe

From Dev

Set button content on button click trigger in xaml

From Dev

Trigger a button when the user click in Enter button

From Java

Get button click inside UITableViewCell

Related Related

  1. 1

    Unable to auto click/trigger on button of iframe

  2. 2

    Zooming a PDF inside an iframe upon Button click

  3. 3

    Not able to click on a button,which is inside an iframe in chrome browser using webdriver

  4. 4

    I cannot click the Admin button nested inside the iFrame

  5. 5

    trigger AJAX action when click on button inside dropdown without closing it

  6. 6

    Button inside the label with the input does not trigger ng-click

  7. 7

    trigger AJAX action when click on button inside dropdown without closing it

  8. 8

    Button inside popup doesn't trigger click event outside the popup

  9. 9

    iFrame on button click

  10. 10

    Trigger storyboard on Button click?

  11. 11

    Button inside an iframe is not working

  12. 12

    button in iframe should trigger event

  13. 13

    JavaScript to click on a div inside iframe

  14. 14

    jQuery: click event inside iframe

  15. 15

    How to display an iframe on button click

  16. 16

    How to display an iframe on button click

  17. 17

    Click on iframe to make a button appear

  18. 18

    Trigger validation on click of Search button

  19. 19

    jQuery trigger reset button click

  20. 20

    Trigger button click on other element

  21. 21

    Not able to click a button which sites inside form which sits under Iframe which sits under table

  22. 22

    trigger button inside a repeater control

  23. 23

    jQuery trigger click event from iframe

  24. 24

    Trigger blur on focused element, on click outside of iFrame

  25. 25

    Trigger radio button click without the click

  26. 26

    Angular 2 trigger interpolation inside an iframe

  27. 27

    Set button content on button click trigger in xaml

  28. 28

    Trigger a button when the user click in Enter button

  29. 29

    Get button click inside UITableViewCell

HotTag

Archive