Web Design Forum: Help with sizing an iframe - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Help with sizing an iframe

#1 User is online   adamsmith 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 336
  • Joined: 04-June 11
  • Reputation: 9
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 07 February 2012 - 12:22 AM

On my site I have a div at the top of the page 97px in height that spreads along the whole top. The rest of the page below is an iframe that loads other sites.

I want the height of the iframe to fill the rest of the page, but if I put height 100% then the size of the window is 100% plus 97px so I end up with 2 scroll bars (1 for the window and 1 for the iframe).

What I want is 100% - 97px but I don't know how to achieve this without using javascript (which is slow in calculating the size it should be).

If I make the bar 10% and the iframe 90% then effectively works perfect until I come to resize the window, the size of the bar at the top changes which I don't want to happen.

It might be easier if you check my site (sorry, I don't mean this to be a plug but it will require you to sign up)

My site

If someone has an alternative method I would very much appreciate it. This is the Javascript code that I am using at the moment.

<body onload="OnPageLoad()" onresize="doResize()">


<script type="text/javascript">
function OnPageLoad() {
	doResize();
	//ajaxArray();
	timedCount();
}
</script>


<script type="text/javascript">
function doResize() { 
 var viewportwidth;
 var viewportheight;
  
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
  
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
  
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
  
 // older versions of IE
  
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }

document.getElementById("frame").height = viewportheight - 97;
}
</script>

0

#2 User is offline   Wickham 

  • Web Guru
  • View gallery
  • Group: Moderators
  • Posts: 2,876
  • Joined: 11-June 09
  • Reputation: 257
  • Gender:Male
  • Location:Salisbury UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 07 February 2012 - 08:09 AM

Fluid heights for iframes are difficult. I think you may have to use javascript. This may help:-
http://www.dynamicdr...ead.php?t=41756
0

#3 User is offline   junior 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 238
  • Joined: 06-July 09
  • Reputation: 5
  • Gender:Male
  • Location:Leeds, UK
  • Experience:Intermediate
  • Area of Expertise:I'm Learning

Posted 10 February 2012 - 01:57 PM

Could you not use the 100% for the iFrame and use a z-index value to bring the bar to the top with a fixed position at the top of the page?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users