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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:35:20+00:00 2026-06-01T11:35:20+00:00

I have an iframe in the same domain as the web page. I have

  • 0

I have an iframe in the same domain as the web page.

I have a header that I would like to keep the same height (I don’t know what it is, let’s say 80px), while the body contains the iframe, which is resized when the browser is resized:

----------        --------------
| header |        |   header   |
----------        --------------
| iframe |   ->   |            |
|        |        |            |
|        |        |    ....    |
----------        |            |
                  |            |
                  --------------

I am using jQuery and have tried height() and css() on the iframe div, but those do not change the iframe‘s dimensions. The iframe remains at the same, small, default dimensions.

If I manually specify percentages in the iframe CSS, then resizing works, but because these are percentages, the iframe goes beyond the immediate page’s borders and gets cut off after a high enough percent value pushes its borders off the screen.

I need some way to help the iframe compute its own borders by pixels, so that it stays within the borders of the page. I can grab the window width and height, but as mentioned, applying css() and height() from those values did not update the iframe‘s size.

Again: I am working with the iframe in the same domain as the parent page.

How would I properly code the resizing of both the header and iframe, so that a resize() operation (or resizing the browser window) actually works?

The code I have tried is something like the following:

<html>
<head>
... // load jquery, etc.
<script>
function resize() { 
    var w = $('#body').width(); 
    var h = $('#body').height();

    $('#header').width(w + "px"); // works
    $('#header').height("80px"); // works

    $('#my_iframe').css("width", w + "px"); // doesn't work
    $('#my_iframe').width(w + "px"); // doesn't work, either

    $('#my_iframe').css("height", (h-80) + "px"); // doesn't work
    $('#my_iframe').height((h-80) + "px"); // doesn't work, either
}
</script>
</head>

<body onresize="resize()" id="body">
<div id="header"><div>
<iframe id="my_iframe" .../>
</body>
</html>
  • 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-01T11:35:21+00:00Added an answer on June 1, 2026 at 11:35 am

    Bind the resize event on the window, and set the height of the iframe:

    $('#content').css('height', ($(window).height() - 80) + 'px');
    

    Demo: http://jsfiddle.net/Guffa/t4b4j/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page with an iframe in it (I don't like it,
I have a same domain iframe within a page that lets users upload unlimited
We have a third-party external web page on another domain that we're loading in
I have an iframe that loads a remote page (not hosted on the same
I don't have access to this iframe's source directly, so I would like to
Lets say I have a page on the same domain that I put inside
i know i can have iframe in a html page, say parent.htm, and i
I have an IFrame app, and I would like to use some Connect features
I have an iframe (same domain), and want to be able to track the
I have a .jsp that contains an IFrame with a page that has some

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.