Resize img inside iframe using jquery

I am using an ad server on my website. All additions use an iframe and I am trying to adjust the img (the first one with width = 728 and height = 90) inside the iframe to change its size (width and height). I was able to target the body (by changing its background color to test), but I am unable to target the image to resize it. here is the iframe code, i need to customize the iframe object and not the iframe class because the class changes every time.

<div class="insert_pub">
  <iframe id="a0811af3" width="" height="90" frameborder="0" scrolling="no" src="/www/delivery/afr.php?zoneid=3&cb=INSERT_RANDOM_NUMBER_HERE" name="a0811af3">
    #document
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
      <head></head>
      <body>
        <a href="/www/delivery/ck.php?oaparams=2__bannerid=212__zoneid=3__cb=9b2dbdb22f__oadest=http%3A%2F%2Fthebayfestival.fr%2F" target="_blank">
          <img src="/www/images/c34d3222b19118f97aa99e76310c70fe.jpg" alt="" title="" height="90" border="0" width="728">
        </a>
        <div id="beacon_9b2dbdb22f" style="position: absolute; left: 0px; top: 0px; visibility: hidden;">
          <img src="/www/delivery/lg.php?bannerid=212&amp;campaignid=176&amp;zoneid=3&amp;loc=http%3A%2F%2Fwww.mmdwc.com%2Fmagazine%2F&amp;cb=9b2dbdb22f" alt="" style="width: 0px; height: 0px;" height="0" width="0">
        </div>
      </body>
    </html>
  </iframe>
</div>

      

here is what i tried but it doesn't work:

function iframe_insert_size() {
  $(".insert_pub iframe").contents().find("img").css({"width":624, "height" : 77});
}

      

+3


source to share


1 answer


You have access to your iFrame with the following sentence:

<script type="text/javascript">


        $(document).ready(function () {

                 $("#a0811af3").on('load', function () {

 $("#a0811af3").contents().find("your image").on("click", function (e) {

              });
       });
});

      



This case works when you click inside the image. This is what you need?

+3


source







All Articles