Posted on 2005-04-20
Last Modified: 2010-04-09
Iam using an IFRAME inside a table. Iam not using any height attribute for the table <TR><td>.... and I have not mentioned any height attribute for IFRAME also. Inside the IFRAME iam displaying a page. When the page gets displayed intside the IFRAME I get a scroll bar, but I want the IFRAME to get extended instead of having a scroll bar.

Need Solution....
Question by:ramsharma23
    LVL 32

    Accepted Solution

    If you don't want to specify any width or height attribute on your iframe, you probably have to resize the <iframe> from the file in the iframe.


    In your main page
    <iframe src="page2.html" id="myIframe"></iframe>

    and page2.html:

        function resizeParent(){
            var obj= parent.document.getElementById('myIframe');
   = (document.body.offsetWidth/1 + document.body.scrollWidth/1) + 'px';
   = (document.body.offsetHeight + document.body.scrollHeight/1) + 'px';
    <body onload="resizeParent()">
    <table width="500" height="500">
    LVL 33

    Expert Comment

    //try this
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    function reSize(){
      var fB = window.frames.frm.document.body; = "hidden";


    <iframe src = "c:\1.html" onLoad="reSize()"  name ="frm" id ="frameid"></iframe>

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now