Posted By

Neven on 02/23/13


Tagged

iframe resize content


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

burnandbass
Abiotic
pedromagalhaes
Beppoi
JeffSFO
bcmoney
Priestd09
williamhillx
fackz


Resize iFrame to its content


 / Published in: JavaScript
 

Bind onload function to the iFrame and set the size of the iFrame to the iFrames loaded content. In the example jQuery is used.

  1. $("#modalIFrame").bind('load',
  2. function () {
  3. var newheight,
  4. newwidth;
  5.  
  6. newheight = this.contentWindow.document.body.scrollHeight;
  7. newwidth = this.contentWindow.document.body.scrollWidth;
  8.  
  9. $(this).height(newheight);
  10. $(this).width(newwidth);
  11. }
  12. );
  13.  
  14. $("#modalIFrame").attr('src', url);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: js1503 on August 25, 2019

charging time, battery life, latest smartphone update

Posted By: brashertreyshawn on September 10, 2019

thanks for sharing i was looking for that

You need to login to post a comment.