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 7403397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:04:18+00:00 2026-05-29T05:04:18+00:00

I am trying to set the height of an iframe dynamically using javascript and

  • 0

I am trying to set the height of an iframe dynamically using javascript and Jquery.

But for reason this is not working in Ie8 & chrome. (But its working fine on firefox)

can some body please help?

Thanks

 function resizePanel() {
         window.console.log("ran the resize panel function");
     var frame = document.getElementsByTagName('iframe')[0];
    if(frame != null) {

        var height;            
        if(self.innerHeight) {
            window.console.log("ran the self.innerHeight");
            height= self.innerHeight;                             
        }
        else if (document.documentElement && (document.documentElement.clientHeight)) {
           window.console.log("ran the clientHeight");
           height = document.documentElement.clientHeight;                           
         }
         else if(document.body) {
           window.console.log("ran the document.body");
           height = document.body.clientHeight;            
         }
         frame.style.height = height - 165 + 'px'         
    }};

    $(document).ready(function() {
        resizePanel();
        $(window).resize(function() {
            resizePanel();
        });
    });  

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(EndRequest);

    function EndRequest(sender, args) {
        resizePanel();
    }
  • 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-05-29T05:04:19+00:00Added an answer on May 29, 2026 at 5:04 am

    The Code works fine on all browsers by changing one line.

    Instead of using

    var frame = document.getElementsByTagName('iframe')[0];
    

    use

    var frame = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_Options_iframe");
    

    The problem was Chrome and IE have hidden Iframes and when we use getElementsByTagName it returns us the array of all iframes. so we try to access [0] index, it was referring to some other iframe.

    I hope this will help.

    The complete code is:

     function resizePanel() {
    
             var frame = document.getElementById("ctl00_ctl00_ContentPlaceHolder1_Options_iframe");
        if(frame != null) {
    
            var height;            
            if(self.innerHeight) {
    
                height= self.innerHeight;                             
            }
            else if (document.documentElement && (document.documentElement.clientHeight)) {
    
               height = document.documentElement.clientHeight;                       
             }
             else if(document.body) {
    
               height = document.body.clientHeight;            
             }
             frame.style.height = height - 165 + 'px'
    
        }};
    
        $(document).ready(function() {
            resizePanel();
            $(window).resize(function() {
                resizePanel();
            });
        });  
    
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_endRequest(EndRequest);
    
        function EndRequest(sender, args) {
            resizePanel();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set the size of my image using getLayoutParams().height/width, but the
I'm trying to set the width and height of an element with javascript to
I'm trying to set the width & height property of an image element i've
I'm trying to set the height of a vertical bar (activityBar) but it does
I'm trying to dynamically create an iframe and set it's base tag before it
This bug is similar to: jQuery reports incorrect element height in Firefox iframe He
Trying to set RowHeight like this(in code): dgvTruckAvail.RowTemplate.Height = 48; Doesnt' work. I also
I am trying to set iframe height onload , here is example http://jsfiddle.net/hN6z3/1/ It
I am trying to dynamically set the height of an image in the BIRT
im trying to set the height of two divs on my page, because my

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.