繁体   English   中英

如何删除从HTML页面加载到iframe中的与我们联系表单?

[英]How to remove contact us form loaded in iframe from html page?

在搜索了很多并尝试5-6个演示之后,却没有为我想要的工作。 我有一个服务页面,其中将其他域(网站)的服务显示为iframe,并且在该iframe下方有我与我们联系的表格,但是我的问题是iframe页面也包含我要删除的与我们联系的页面。

是否可以删除从iframe源加载的表单?

编辑:我的代码

<script type="text/javascript">

function remove_elemment() {
    var form = document.forms;


        form.style.display = "none";

    }
};

function doRemove() {
    document.frame.document.getElementById('my_iframe').remove_elemment();
}();

</script>
<div class="floating-widget">
    <iframe id="my_iframe" src="http://192.168.0.104/wordpress/?p=1" frameborder="0" width="100%" height="800">             
    </iframe>

</div>

和HTML中加载的评论表格如下

<div id="respond" class="comment-respond">
   <h3 id="reply-title" class="comment-reply-title">Leave a Reply <small><a rel="nofollow" id="cancel-comment-reply-link" href="/wordpress/?p=1#respond" style="display:none;">Cancel reply</a></small></h3>
   <form action="http://192.168.0.104/wordpress/wp-comments-post.php" method="post" id="commentform" class="comment-form" novalidate="">
      <p class="comment-notes"><span id="email-notes">Your email address will not be published.</span> Required fields are marked <span class="required">*</span></p>
      <p class="comment-form-comment"><label for="comment">Comment</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>
      <p class="comment-form-author"><label for="author">Name <span class="required">*</span></label> <input id="author" name="author" type="text" value="" size="30" maxlength="245" aria-required="true" required="required"></p>
      <p class="comment-form-email"><label for="email">Email <span class="required">*</span></label> <input id="email" name="email" type="email" value="" size="30" maxlength="100" aria-describedby="email-notes" aria-required="true" required="required"></p>
      <p class="comment-form-url"><label for="url">Website</label> <input id="url" name="url" type="url" value="" size="30" maxlength="200"></p>
      <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Post Comment"> <input type="hidden" name="comment_post_ID" value="1" id="comment_post_ID">
         <input type="hidden" name="comment_parent" id="comment_parent" value="0">
      </p>
   </form>
</div>

这对我有用

$('#MainPopupIframe').on('load', function(){
    $(this).contents().find("#formOrButtonToRemove").Remove();
});

如果iframe来源(服务页面)不是来自同一域,并且使用的协议与您的页面使用的协议不同,则由于同源政策,它将无法工作。 但是,如果您的页面在同一域中并且使用相同的协议,则可以使用它来删除联系表单。 $("#iframeId").contents().find("#contactformdiv").remove();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM