jQuery: Cách tự động định chiều cao của iframe
Để tự động điều chỉnh chiều cao của iframe, ta có thể làm như ví dụ sau:
<!DOCTYPE html> <html> <head> <title></title> <script src="https://code.jquery.com/jquery-latest.js"> </script> </head> <body> <iframe src="https://v1study.com/demo/css3-flex-wrap-wrap-reverse.html" style="width:100%; border:none;"></iframe> <script> $(function(){ $("iframe").attr("onload","style.height=contentWindow.document.body.scrollHeight+10+'px'"); }); </script> </body> </html>
Kết quả: