Html 表单目标是iframes的父级

Html 表单目标是iframes的父级,html,forms,webforms,parent,Html,Forms,Webforms,Parent,我有一个表单在iframe中,我需要确保表单提交给iframe的父级。Target=“\u top”和Target=“\u parent”不起作用,我开始对自己有点恼火 如果有人能给我指出正确的方向,那就太棒了。:) 我有一个正常的带src的iframe到一个html页面-那个html页面有这个 <form action="#" method="post" target="_parent" > <table id="Table_01" width="308" height=

我有一个表单在iframe中,我需要确保表单提交给iframe的父级。Target=“\u top”和Target=“\u parent”不起作用,我开始对自己有点恼火

如果有人能给我指出正确的方向,那就太棒了。:)

我有一个正常的带src的iframe到一个html页面-那个html页面有这个

<form action="#" method="post" target="_parent" >
  <table id="Table_01" width="308" height="411" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="6">
            <img src="index_01.png" width="308" height="163" alt=""></td>
    </tr>
    <tr>
        <td colspan="2" rowspan="4">
            <img src="index_02.png" width="112" height="142" alt=""></td>
        <td colspan="3" style="background-image: url('optin_name.png');" width="189" height="40" alt="">
         <input type="text" name="name" style="background: transparent;border:0px;font-size:25px;width:185px;height:37px">
        </td>
        <td rowspan="6">
            <img src="index_04.png" width="7" height="247" alt=""></td>
    </tr>
    <tr>
        <td colspan="3">
            <img src="index_05.png" width="189" height="33" alt=""></td>
    </tr>
    <tr>
        <td colspan="2" style="background-image: url('optin_email.png');" width="188" height="40" alt="">
            <input type="text" name="email" style="background: transparent;font-size:25px;border:0px;width:185px;height:37px;">
        </td>
        <td rowspan="4">
            <img src="index_07.png" width="1" height="174" alt=""></td>
    </tr>
    <tr>
        <td colspan="2">
            <img src="index_08.png" width="188" height="29" alt=""></td>
    </tr>
    <tr>
        <td rowspan="2">
            <img src="index_09.png" width="73" height="105" alt=""></td>
        <td colspan="2" style="background-image: url('optin_submit.png');" width="174" height="54" alt="">
            <input type="submit" name="submit" value="                 " style="background: transparent;border:0px;width:170px;height:50px;">
        </td>
        <td rowspan="2">
            <img src="index_11.png" width="53" height="105" alt=""></td>
    </tr>
    <tr>
        <td colspan="2">
            <img src="index_12.png" width="174" height="51" alt=""></td>
    </tr>
    <tr>
        <td>
            <img src="spacer.gif" width="73" height="1" alt=""></td>
        <td>
            <img src="spacer.gif" width="39" height="1" alt=""></td>
        <td>
            <img src="spacer.gif" width="135" height="1" alt=""></td>
        <td>
            <img src="spacer.gif" width="53" height="1" alt=""></td>
        <td>
            <img src="spacer.gif" width="1" height="1" alt=""></td>
        <td>
            <img src="spacer.gif" width="7" height="1" alt=""></td>
    </tr>
</table>
</form>


我无法将其发布到iframe父窗口,而不是在新窗口中和/或在iframe本身内部,两者都不是“否”。

表单中的
操作
属性似乎有问题。您想将数据发布到哪个URL?尝试用目标URL替换action属性中的
#

  • 防止默认提交行为
  • 使用
    window.parent
    访问父级
  • 让父对象在iframe中发布其表单值

  • 你能分享相关的代码片段吗?仅仅因为你的答案也是有效的,你就投票吧。
    $("#myform").submit(function(event) {
        event.preventDefault();
        var val = $(this).find('input[type="text"]').val();
    
        // I like to use defers :)
        deferred = $.post("http://somewhere.com", { val: val });
    
        deferred.success(function () {
            // Do your stuff.
        });
    
        deferred.error(function () {
            // Handle any errors here.
        });
    });