簡體   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