将文本插入到iFrame中的表单中,然后单击提交 [英] Insert Text into a Form in iFrame and click on Submit

查看:123
本文介绍了将文本插入到iFrame中的表单中,然后单击提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的。我基本上想要在我的网站上创建一个iframe,并通向我的其他网站。

在我的iFramed网站上,我有一个带有文本框和提交按钮的窗体。我想插入一些文本到文本字段,然后点击提交按钮当我点击站点A(包含iframe的按钮)的按钮时。



有没有可能以某种方式?



我曾尝试过这种做法,但似乎并不奏效:

 < script type =text / javascript> 
函数insertTxt(){
var textstring =测试成功;
window.frames [iframeAB]。document.documentElement.getElementsByTagName(textarea)[0] .value = textstring;
}
< / script>

< iframe name =iframeABsrc =index.htmlid =qabwidth =100%height =210style =border:1px solid#009ee0> ;
您的浏览器无法处理iframe
< / iframe>
< input type =buttonvalue =Goonclick =top.frames ['iframeAB']。window.document.body.getElementById('text_field')。value ='test successful'; />
< a href =#onclick =insertTxt();>测试< / a>


解决方案

您可以尝试以下解决方案:



它使用JQuery

您的HTML

 < iframe name =iframeABsrc =index.htmlid =qabwidth =100%height =210style =border:1px solid# 009ee0\" > 
您的浏览器无法处理iframe
< / iframe>
< input type =buttonvalue =Goonclick =top.frames ['iframeAB']。window.document.body.getElementById('text_field')。value ='test successful'; />
< a href =#onclick =insertTxt();>测试< / a>

JS文件中的insertTxt()方法

  $(#qab)。ready(function(){
$(#qab)。contents()。find( ('test');
});


Alright. I basically want to create an iframe on my website which leads to my other website.

On my iFramed website I have a form with a Text Field and a Submit button. I would like to insert some text to the Text Field and then Click on the submit button WHEN I click on a button at Site A (the one which contains the iframe).

Is it possible in some way?

I have tried the follwoing but it doesn't seems to work:

<script type="text/javascript">
    function insertTxt() {
        var textstring = "test successful";
        window.frames["iframeAB"].document.documentElement.getElementsByTagName("textarea")[0].value = textstring;
    }
</script>

<iframe name="iframeAB" src ="index.html" id="qab" width="100%" height="210" style="border:1px solid #009ee0">
    Your browser doesn't handle iframes
</iframe>
<input type="button" value="Go" onclick="top.frames['iframeAB'].window.document.body.getElementById('text_field').value='test successful';"/>
<a href="#" onclick="insertTxt();">test</a>

解决方案

You might try this solution:

It uses JQuery

Your HTML

<iframe name="iframeAB" src ="index.html" id="qab" width="100%" height="210" style="border:1px solid #009ee0">
    Your browser doesn't handle iframes
</iframe>
<input type="button" value="Go" onclick="top.frames['iframeAB'].window.document.body.getElementById('text_field').value='test successful';"/>
<a href="#" onclick="insertTxt();">test</a>

insertTxt() method in JS file

$("#qab").ready(function() {
    $("#qab").contents().find("body").find('textarea').val('Test Successful');
});

这篇关于将文本插入到iFrame中的表单中,然后单击提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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