467,074 Members | 1,089 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

Problems resizing iframe

sorry moved this over to javascript forum, didn't mean to post 2x!

Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page includes background music with a javascript music player on the main page below an iframe that is used for all content and navigation of the site and so that the music doesn't reload each time a page is switched. There is another javascript to resize the iframe to fit the content, so that it will adjust to the various page heights. The problem I'm having now is that it won't resize until it loads all the content (which includes some sizeable flash etc) and it is freezing during the resize process. It does however begin playing the music before resizing the iframe, and generally locks up saying it is still loading the indexforinline.htm, though it never actually completes and resizes (although I can hear my flash content loading working correctly -- the iframe is just not resized). Then I simply have to reload the iframe by clicking refresh, and it will appear correctly (now that the content is loaded) I'm thinking that it is loading the content ( i can hear it) , but not resizing the iframe in time to display it. One thing I would like to do is not load the music player until the iframe is loaded and resized, but this will only solve the resize problems on the homepage (or so I assume, because I have the same resize problems when navigating to other pages, and have to refresh them as well to get them to resize the iframe and display correctly)

Here is the code involved with the index.htm:

//script to resize iframe to correct height depending on content

<script language="JavaScript">
<!--
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindo w.
document.body.scrollHeight;

//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
//-->
</script>

</head>


<body bgcolor="#000000">

// Iframe loaded with indexforinline.htm containing all content and navigation
<p align="center">
<iframe width="1000" id="the_iframe"
onLoad="calcHeight();"
src="indexforinlinetest.htm"
scrolling="NO"
frameborder="0"
height="1">An iframe capable browser is
required to view the website.</iframe>

//background music player loaded to index.htm

<table align="right" border="0" cellspacing="0"cellpadding="0"><tbody><tr><td>
<div align="right">
<script language='JavaScript' src='musicplayer.js' type='text/javascript'></script></div>
<tr><td>
<p align="right">&nbsp;</td></tr></tbody></table>

<script language="JScript" type="text/jscript" src="../NoIEActivate.js"></script>

</body>



Anything you guys can suggest to ensure that the iframe resizes and displays correctly without refreshing the iframe would be greatly appreciated!! Thanks!!
Oct 13 '06 #1
  • viewed: 4088
Share:
3 Replies
Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page includes background music with a javascript music player on the main page below an iframe that is used for all content and navigation of the site and so that the music doesn't reload each time a page is switched. There is another javascript to resize the iframe to fit the content, so that it will adjust to the various page heights. The problem I'm having now is that it won't resize until it loads all the content (which includes some sizeable flash etc) and it is freezing during the resize process. It does however begin playing the music before resizing the iframe, and generally locks up saying it is still loading the indexforinline.htm, though it never actually completes and resizes (although I can hear my flash content loading working correctly -- the iframe is just not resized). Then I simply have to reload the iframe by clicking refresh, and it will appear correctly (now that the content is loaded) I'm thinking that it is loading the content ( i can hear it) , but not resizing the iframe in time to display it. One thing I would like to do is not load the music player until the iframe is loaded and resized, but this will only solve the resize problems on the homepage (or so I assume, because I have the same resize problems when navigating to other pages, and have to refresh them as well to get them to resize the iframe and display correctly)

Here is the code involved with the index.htm:

//script to resize iframe to correct height depending on content

<script language="JavaScript">
<!--
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindo w.
document.body.scrollHeight;

//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
//-->
</script>

</head>


<body bgcolor="#000000">

// Iframe loaded with indexforinline.htm containing all content and navigation
<p align="center">
<iframe width="1000" id="the_iframe"
onLoad="calcHeight();"
src="indexforinlinetest.htm"
scrolling="NO"
frameborder="0"
height="1">An iframe capable browser is
required to view the website.</iframe>

//background music player loaded to index.htm

<table align="right" border="0" cellspacing="0"cellpadding="0"><tbody><tr><td>
<div align="right">
<script language='JavaScript' src='musicplayer.js' type='text/javascript'></script></div>
<tr><td>
<p align="right">&nbsp;</td></tr></tbody></table>

<script language="JScript" type="text/jscript" src="../NoIEActivate.js"></script>

</body>



Anything you guys can suggest to ensure that the iframe resizes and displays correctly without refreshing the iframe would be greatly appreciated!! Thanks!!
Oct 13 '06 #2
hmm the resize seems to be working in firefox, although it still loads and plays the flash objects in indexforinline.htm before the iframe is resized (don't get to see flash -- can hear it though), so this is something I would like to fix, to make sure the user sees the flash animations. (make the ifreame resize before the contents of indexforinline.htm is displayed) Internet explorer just hangs saying it is waiting on one item to finish loading from indexforinline.htm and the only way it will resize is by refreshing the iframe. any help or suggestions would be great. the main goal here is to have the music playing in the background without restarting when navigating to another page so maybe there is an easier way to do this? Thanks!!
Oct 14 '06 #3
someone recommended calling the resize from within the indexforinline.htm (content displayed in iframe) using document.parentSomethingOfOther.size = blah but not sure exactly how to go about doing this any suggestions would be appreciated
Oct 14 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by khothikhe | last post: by
1 post views Thread by khothikhe | last post: by
1 post views Thread by Paul Fi | last post: by
1 post views Thread by marco.dini@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.