0

I want to hide watermark from iframe, I tried with css and script as well still not able to hide it .

I am passing url in src"" of iframe

CODE :

<iframe scrolling="no" class="testFrame" id="frame1"></iframe>
<script>
    var iframe = document.getElementById("frame1");
    iframe.onload = function () {
        $("#frame1").contents().find(".lt").hide();
    }
</script>

1 Answers1

0

An iframe is a 'hole' in your page that displays another web page inside of it. The contents of the iframe are not in any shape or form part of your parent page.

Give the file that is being loaded in the iframe the necessary CSS if the file in the iframe is from the same domain as your parent, then you can access the DOM of the document in the iframe from the parent.

Considering the iframe is from the same domain, Try using the below code and see if it works.

<script>
 var iframe = document.getElementById("frame1");
$('iframe').load( function() {
    $('iframe').contents().find("head")
      .append($("<style type='text/css'>  .lt{display:none;}  </style>"));
});
</script>

If you are getting "permission denied type errors.", I think what you are doing is subject to the same-origin policy. This should be the reason why you are getting permission denied type errors.

Here you can check the possible solutions.

Unable to access iframe content (same-origin policy)

Rajeev
  • 1,376
  • 2
  • 15
  • 33
  • Thanks Rajeev , Actually it comes from another origin . Is there any solution for this ? – Priyanka Shinkar Mar 04 '20 at 09:49
  • The only possibility to control the iframe content loading from another origin would be to load the iframe content through a proxy of yours and modify the HTML content. You can not access iframes from another domain via JavaScript. If this answer helps you, Do accept the answer and upvote – Rajeev Mar 04 '20 at 09:57