Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Script malfunctioning to autosize iframe - Help needed

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Joep

Established Member
Impact
11
Hello everyone,

I encountered a problem while trying to create a sitepage with a dropdown menu and an iframe.
The options in the menu must load in the iframe.
I need the iframe in this page to resize it's height to the size of the page that loads in it.
The current 3 pages that have to load in the iframe all have different heights.
Hopefully someone can help me with this.

This is the html :

Code:
<!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>
<title>My Website</title>

<script type="text/javascript">
function SetIFrame()
{
myFrm = document.getElementById('myIFrame');
myFrm.src = document.mapform.jump.options[document.mapform.jump.selectedIndex].value;
}
</script>

<script>
function alertsize(pixels){
pixels+=32;
document.getElementById('myIFrame').style.height=pixels+"px";
}
</script>

</head>
<body bgcolor="#FFFFFF" text="#5C5457" link="000000" vlink="000000" alink="000000">
<div align="center">
<table width="70%" border="1" bordercolor="#333333">
<tr>
<td>
<div align="center">
<br />
<br />
<form name="mapform" method="post">
<p>
<br />
<select name="jump" size="1">
<option value="http://www.mydomain.com/products1.html">Products part 1</option>
<option value="http://www.mydomain.com/products2.html">Products part 2</option>
<option value="http://www.mydomain.com/products3.html">Products part 3</option>
<option value="" selected="selected">select</option>
</select>
<input type=button onclick="SetIFrame()" value="Go" />
</p>
</form>
<div align="center">
<iframe id="myIFrame" name="Frame1" width="1045" src="http://www.mydomain.com/main.html" frameborder="0" scrolling="no" body onload="parent.alertsize(document.body.scrollHeight);"></iframe>
</div>
<br />
</div>
</td>
</tr>
</table>
</div>
</body>
</html>

Can anyone please help me solve this?
Thanks a lot in advance for your help!
 
Last edited by a moderator:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Um why are you using an iFrame instead of a div?
 
Last edited:
0
•••
What are you trying to do?

You want the iframe to inherit the height of the page it's opening, have you thought about implementing it some other way? Are you trying to display external websites?
 
0
•••
Problem solved.
I contacted a guy on Fiverr and for 5 bucks he made me the page (using div instead of iframe).
Thanks for your help.
 
0
•••
Thread closed :)
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back