By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,429 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

Problems resizing iframe

P: 4
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
Share this Question
Share on Google+
3 Replies


P: 4
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

P: 4
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

P: 4
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.