dynamic iframe height


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 13 of 13

Thread: dynamic iframe height

  1. #1
    Join Date
    Mar 2008
    Location
    BELGIUM - East Flanders
    Posts
    174

    dynamic iframe height

    I'm seraching for a way to adapt the height of an iframe to it's contents.
    Is this possible? if yes: how?

    Thnx in advance

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Does this help?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Mar 2008
    Location
    BELGIUM - East Flanders
    Posts
    174
    Nope, i know how to make static iframes, but i need to know how i can make the height dynamic

  4. #4
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    kanu you use java-script ?
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  5. #5
    Join Date
    Mar 2008
    Location
    BELGIUM - East Flanders
    Posts
    174
    The properies of nodes in parent window are read-only... so i can't change the bloody height from within the iframe...

  6. #6
    Join Date
    Jan 2008
    Location
    http://www.GlobalGuideLine.com
    Posts
    12

    Wink Height of iframe and its content.

    hi i think we can change the height and width of i frame at run time but if u are asking about the height and width of content of iframe i think we cant do this.
    if you got how to get access the content of iframe then plz guide me too.
    Thanks.
    Ali.
    Online Web Tutorials http://www.GlobalGuideLine.com

  7. #7
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    yea of course you kan using javascript:

    Code:
    <iframe width=200 height =300 id="fra">
    </iframe>
    <input type="button" onclick="document.getElementById('fra').height=400;">
    click on the button near the ifram and you will see increasing in height by 100px .
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  8. #8
    Join Date
    Mar 2008
    Location
    BELGIUM - East Flanders
    Posts
    174
    yeah ali_ggl, thats what i'm starting to think to.

    @ Amahdy:
    I know how to change the seize of an iframe, thats not my problem. But if i do it like in your example, then it'll always get an height of 400px. Problem with that is that it looks kinda nub when the content page has only one line of text. So i want the height to be dependent on the content of the iframe...

  9. #9
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    you kan adjust it onchange() ... and this kould be easily changed to anything .. for example :

    document.getElementById('fra').height=document.getElementById('fra').height+100

    you kan work around it to make it closely appropriate and change when there is new line ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  10. #10
    Join Date
    Mar 2008
    Location
    BELGIUM - East Flanders
    Posts
    174
    That will just increase the height with 100px, again not dependant on the iframe contents
    Or am i missing something?

  11. #11
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    yea i told you in the onchange I meant after loading the page for example .. try to adjust the height by some scripting depending on the framed page ... this won't be very correct sometimes that's why I said "closely appropriate" ... this may help a bit ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  12. #12
    Join Date
    Mar 2008
    Location
    BELGIUM - East Flanders
    Posts
    174
    Yeah, i can do it like that, but i don' think it's the way this problem should be solved.

    Anyone another idea?

  13. #13
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Play around with this
    Code:
    <HTML>
    <Head>
    <Script type="text/javascript">
    
    function adjustFrame(){
    
    window.frames.IFrame1.scrollBy(0,900);
    currTop = window.frames.IFrame1.document.body.scrollTop;
    if (currTop > 0)
    {
    currHeight = document.getElementById('dynFrame').getAttribute('height');
    currHeight++;
    document.getElementById('dynFrame').setAttribute('height',currHeight);
    adjustFrame();
    }
    }
    
    function setHeight(){
    
    document.getElementById('dynFrame').setAttribute('height',0);
    adjustFrame();
    }
    
    </Script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
    <!--
    body {
    	margin-left: 0px;
    	margin-top: 0px;
    	margin-right: 0px;
    	margin-bottom: 0px;
    }
    -->
    </style></Head>
    <Body>
    
    <IFrame
    Name = 'IFrame1'
    Id ='dynFrame'
    Src = 'http://www.settmedia.no/nidaros/phpBB2/'
    onload = 'setHeight()'
    marginwidth = '0' 
    marginheight ='0' 
    frameborder = '0' 
    vspace = '0' 
    hspace = '0'
    Width = '750'
    Height = '150'>
    </IFrame>
    
    </Body>
    </HTML>
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 0
    Last Post: 02-09-2008, 07:02 PM
  2. IE + Iframe popup problem
    By rakeshp in forum AJAX
    Replies: 1
    Last Post: 04-20-2007, 09:07 PM
  3. Replies: 0
    Last Post: 07-19-2005, 01:25 PM
  4. Dynamically resize IFRAME??
    By Ram in forum Web
    Replies: 1
    Last Post: 08-19-2002, 07:18 PM
  5. Help needed before 25/1/01!!!!
    By Chris reid in forum Java
    Replies: 3
    Last Post: 02-11-2001, 09:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center