Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8765775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:22:20+00:00 2026-06-13T16:22:20+00:00

I used a javascript resize function i found on stackoverflow and it works great

  • 0

I used a javascript resize function i found on stackoverflow and it works great with IE and FF. However in Google Chrome it can only resize iframes that are bigger than the previous one. If it has to resize smaller iframes, it takes the same height and adds 30px.

I assume it has got something to do with retrieving the scrollHeight, but i don’t know how to fix it.

I already tried to use a timeout because I read somewhere that might help, but it doesn’t.

Here’s the relevant code:

    function autoResize(id){
        var newheight;
        if(document.getElementById)
        {
            newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
            newheight=newheight+30;
        }
        document.getElementById(id).height = (newheight) + "px";
    }

    <iframe src="<?php echo "$LC"; ?>/home.html" name="iframe" id="iframe" width="435px" height="10px" scrolling="no" frameborder="0" style="margin-left:-10px;padding-bottom:20px;" onLoad="setTimeout(autoResize('iframe'),250);";">

Edit: solved it by changing the function to

    function autoResize(id) {
        document.getElementById(id).height = document.getElementById(id).contentDocument.documentElement.scrollHeight+15; //Chrome

        document.getElementById(id).height = document.getElementById(id).contentWindow.document.body.scrollHeight+15; //FF, IE
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:22:22+00:00Added an answer on June 13, 2026 at 4:22 pm
    function autoResize(id) {
        document.getElementById(id).height = document.getElementById(id).contentDocument.documentElement.scrollHeight+15; //Chrome
    
        document.getElementById(id).height = document.getElementById(id).contentWindow.document.body.scrollHeight+15; //FF, IE
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used Javascript onlaod like this: function check() { var pic = new
i used a javascript code for radiobtn check inside gridview. the code works fine
I know ClientID is used for javascript and UniqueId for server side and that
I'm used to debugging JavaScript in Chrome or Firefox just because their built in
I have dealt and used JavaScript and am quite comfortable with it. However I
I have a google maps app that will resize the map div if its
I've only ever used javascript on HTML pages (dom manipulation, AJAX calls, you know
I have used JavaScript on body onload event I used this code: function timeMsg()
Using web forms I know that you can only have one ASP.NET form on
I have used javascript (and jquery) to use google api for its search engine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.