在iframe内触发一个按钮点击 [英] Trigger a button click inside an iframe

查看:1020
本文介绍了在iframe内触发一个按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是iframe代码:

 < div id =OutDivclass =outerdiv> 
< iframe src =http://beta.sportsdirect.bg/checkout/onepage/id =InnerIframeclass =FrameCSSscrolling =no>< / iframe>
< / div>

以下是上面调用的iframe的按钮的HTMl代码:

 < button type =buttonid =SuperWebF1title =Continueclass =button>继续< / button> 

这里是我用来在加载页面时触发点击按钮的jQuery函数:

  $('#SuperWebF1')。trigger(click); 

但是,只有当我将jQuery代码放入按钮源和iframe正在用脚本调用按钮。



我想创建一个事件,它是从iframe外部单击按钮。
是否有可能?



预先感谢!

解决方案

< pre $ window.load(function(){
$('#InnerIframe')。contents()。find('#SuperWebF1')。trigger(click);
});


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!

解决方案

window.load(function(){
   $('#InnerIframe').contents().find('#SuperWebF1').trigger( "click" );
});

这篇关于在iframe内触发一个按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆