944,117 Members | Top Members by Rank

Ad:
Dec 6th, 2006
0

iframe help - Height

Expand Post »
I have this code that won't display the iframe properly. When I use it, the iframe spans accross the page, but won't span down, fitting the entire page.

HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a rel="nofollow" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
  2. <html xmlns="<a rel="nofollow" href="http://www.w3.org/1999/xhtml" target="_blank"> http://www.w3.org/1999/xhtml</a> ">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title> WinBetaSecrets- Connecting the Beta Community</title>
  6. <style type="text/css">
  7. <!--
  8. body {
  9. background-image: url(<a rel="nofollow" href="http://www.winvistasecrets.com/network/templates/ja_sargas/images/body-bg.jpg" target="_blank"> http://www.winvistasecrets.com/netwo...es/body-bg.jpg</a> );
  10. background-repeat: no-repeat;
  11. }
  12. .style3 { color: #FFFFFF;
  13. font-size: 18px;
  14. font-weight: bold;
  15. }
  16. -->
  17. </style> </head>
  18. <body>
  19. <div align="center"> <a href="<A href="http://www.winvistasecrets.com/network"><img"> http://www.winvistasecrets.com/network"><img src="<a rel="nofollow" href="http://www.winvistasecrets.com/network/templates/ja_sargas/images/logo.png" target="_blank">http://www.winvistasecrets.com/netwo...mages/logo.png</a>" alt="logo" width="584" height="109" border="0" /></a></div>
  20. <p align="left">&nbsp;</p>
  21. <div style="height:100%; width:100%;">
  22. <iframe src="<a rel="nofollow" href="http://thevistageeks.com/forums/index.php?act=idx" target="_blank"> http://thevistageeks.com/forums/index.php?act=idx</a> " height="100%" width="100%" frameborder="0" scrolling="yes">
  23. </iframe>
  24. </div>
  25. </body>
  26. </html>
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
Wreef is offline Offline
40 posts
since Aug 2006
Dec 8th, 2006
0

Re: iframe help - Height

Can someone please help?
Reputation Points: 10
Solved Threads: 1
Light Poster
Wreef is offline Offline
40 posts
since Aug 2006
Dec 8th, 2006
0

Re: iframe help - Height

100% height doesn't really mean anything in standards compatible mode... (XHTML Transitional is one of those modes).. It means 100% of the parent object height... So if the parent object ( a body element) has no height (the height of a body element is usually the height of its contents), then the height of the iframe will be the default iframe height, which then occupies 100% of the body element's height... you could try setting the body height to 100% (i.e. <body style="height:100%;">).. I've heard that can work in some cases, but it seems a bit nonsensical...
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Dec 8th, 2006
0

Re: iframe help - Height

I am having the same problem. One of the solutions posted previously had the following info, however I was not able to figure it out. I tried the following code, but still does not work. Am I calling the function wrong?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
* { margin: 0; padding: 0;}
</style>
<script type="text/javascript">
function resize_iFrames(){
for (var i=0; i<sTitleArray.length; i++){
siFrameID = "iFrame" + sTitleArray[i];
//DHTML (used to get DIV inside of iFrame)
var oDHTMLiFrame = document.frames[siFrameID];
var oDHTMLiFrameDocument = oDHTMLiFrame.document
// DOM (used to set height of iFrame on this page)
var oDOMiFrame = document.getElementById(siFrameID);
var oDOMiFrameDocument = oDOMiFrame.document
// wait til document's data is completely loaded then resize iFrame surrounding it
while (oDHTMLiFrameDocument.readyState != "complete" ) {}
var oDIVwholePage = oDHTMLiFrameDocument.all['DIVwholePage']; // dhtml object model
// You can NOT get oDIVwholePage using DOM. That is, you can't get it using oDOMiFrameDocument.getElementById('DIVwholePage').
// MUST use DHTML model to GET the DIV inside the document inside the iFrame::: oDHTMLiFrame.window.document.all['DIVwholePage']
// MUST use DOM model to set the height of the iFrame!!! DHTML does not let me set height
oDOMiFrame.height = oDIVwholePage.offsetHeight+20;
}
}
</script>

</head>
<body>
<h1>Careers</h1>
<p>
&lt; <a href="javascript:history.back();">back</a></p>
<IFRAME name=Original id=Original frameborder=1 src='http://www.recruitingcenter.net/clients/sybron/publicjobs/' onLoad='resize_iFrames()'> </IFRAME>
</body>
</html>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blakisa is offline Offline
7 posts
since Dec 2006
Dec 8th, 2006
0

Re: iframe help - Height

erm... that script seems to work based on a naming convention.. it's searching for iframes thta have IDs like "iFrame_[name]", where [name] is a value in an array called sTitleArray...

if you only have one iframe change the javascript code to:
function resize_iFrames(){
for (var i=0; i<sTitleArray.length; i++){
siFrameID = "Your iframe id"
// DOM (used to set height of iFrame on this page)
var oDOMiFrame = document.getElementById(siFrameID); 


//DHTML (used to get DIV inside of iFrame)
var oDHTMLiFrame = document.frames[siFrameID];
var oDHTMLiFrameDocument = oDHTMLiFrame.document

var oDOMiFrameDocument = oDOMiFrame.document
// wait til document's data is completely loaded then resize iFrame surrounding it
while (oDHTMLiFrameDocument.readyState != "complete" ) {} 
var oDIVwholePage = oDHTMLiFrameDocument.all['DIVwholePage']; // dhtml object model
// You can NOT get oDIVwholePage using DOM. That is, you can't get it using oDOMiFrameDocument.getElementById('DIVwholePage').
// MUST use DHTML model to GET the DIV inside the document inside the iFrame::: oDHTMLiFrame.window.document.all['DIVwholePage']
// MUST use DOM model to set the height of the iFrame!!! DHTML does not let me set height
oDOMiFrame.height = oDIVwholePage.offsetHeight+20;

}
}
(remove the greyed out parts, change the ID to the ID of your frame.

That code also seems to resize the iFrame relative to its contents... you may want to change the section in blue to:
oDOMiFrame.height = document.height;
OR..
oDOMiFrame.height = window.height;

you may want to check out the table halfway down this page to find out which "height" you want...
http://www.quirksmode.org/js/doctypes.html
Last edited by MattEvans; Dec 8th, 2006 at 4:36 pm.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Dec 8th, 2006
0

Re: iframe help - Height

Thanks appreciate the quick response :cheesy: Okay i tried it, however, it seems to still not automatically remove the scroll bars and make the height 100%. Here is the updated code. I tried a local file but still teh same issue. Any thoughts. Can someone try running the following from a browser to test it?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
* { margin: 0; padding: 0;}
</style>
<script type="text/javascript">
function resize_iFrames(){
siFrameID = "Original";
var oDHTMLiFrame = document.frames[siFrameID];
var oDHTMLiFrameDocument = oDHTMLiFrame.document
var oDOMiFrame = document.getElementById(siFrameID);
var oDOMiFrameDocument = oDOMiFrame.document
while (oDHTMLiFrameDocument.readyState != "complete" ) {}
var oDIVwholePage = oDHTMLiFrameDocument.all['DIVwholePage']; // dhtml object model
oDOMiFrame.height = oDIVwholePage.offsetHeight+20;
}
</script>
</head>
<body>
<h1>Careers</h1>
<IFRAME name=Original id=Original frameborder=0 onLoad="resize_iFrames();"
src='http://www.recruitingcenter.net/clients/sybron/publicjobs/' >
</IFRAME>
</body>
</html>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blakisa is offline Offline
7 posts
since Dec 2006
Dec 8th, 2006
0

Re: iframe help - Height

well, here's a solution... it uses a Timer, so it's not optimal... but it should work on all browsers...

HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title></title>
  6. <style type="text/css">
  7. * { margin: 0; padding: 0;}
  8. </style>
  9. <script type="text/javascript">
  10. function lock_iFrame(named){
  11. var thisTimer = setTimeout("resize_iFrame('"+named+"')", 1000);
  12. return thisTimer;
  13. }
  14. function resize_iFrame(named){
  15. siFrameID = named;
  16. var targetFrame = document.getElementById(siFrameID);
  17. targetFrame.height = getHeight() - targetFrame.offsetTop;
  18. }
  19. /*This code is adapted from code in the example at http://www.howtocreate.co.uk/tutorials/javascript/browserwindow. Check it out, it's quite informative*/
  20. function getHeight() {
  21. var myHeight = 0;
  22. if(typeof(window.innerHeight)=='number'){
  23. //Non-IE
  24. myHeight = window.innerHeight;
  25. }else if(document.documentElement && document.documentElement.clientHeight){
  26. //IE 6+ in 'standards compliant mode'
  27. myHeight = document.documentElement.clientHeight;
  28. }else if(document.body && document.body.clientHeight){
  29. //IE 4 compatible
  30. myHeight = document.body.clientHeight;
  31. }
  32. return myHeight;
  33. }
  34.  
  35. </script>
  36. </head>
  37. <body onLoad="lock_iFrame('Original');">
  38. <h1>Careers</h1>
  39. <IFRAME name=Original id=Original frameborder=0 style="width:100%;"
  40. src='http://www.recruitingcenter.net/clients/sybron/publicjobs/' >
  41. </IFRAME>
  42. </body>
  43. </html>

EDIT: This code isn't really network-dependant; so it should work in a local file. I've tested it in a local file on Opera and Firefox 2.. I don't have IE on this computer so I can't test it there...
Last edited by MattEvans; Dec 8th, 2006 at 8:26 pm.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Dec 11th, 2006
0

Re: iframe help - Height

Thanks Matt. Seems to work in IE. One last issue is that when you do a click through the following pages still seem to add the scroll bar. So the first page is good but when you use the IFRAME or click the submit in it. Maybe IFRAME does not send the info back and forth and is limited this way?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blakisa is offline Offline
7 posts
since Dec 2006
Dec 11th, 2006
0

Re: iframe help - Height

Here is the web site im hosting it on.

http://www.kennethking.com/_private/...ellnewtest.php
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blakisa is offline Offline
7 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Iframe opening new window problem
Next Thread in HTML and CSS Forum Timeline: Res. Form/Dreamweaver 8/Email to Address





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC