Forum Moderators: open
I have an inline frame that needs to be reloaded whenever the window is resized like the user maximizes it or stretches it, something like that. I'm sure it is very simple but i have yet to get it to work mostly because i have never used javascript i'm sure ...
<script language="JavaScript">
window.onResize="What do i put here to reload a frame by name";
</script> Like i said i have never used js before so i'm sure that even if i nwe what to put in the quotes I probably don't have the thing setup right anyway. Any help would be appreciated
This should give you what you need. You have a global event handler for the resize event which calles the resizeFrame() function.
<script type="text/javascript">
<!--
window.onresize=resizeFrame()
function resizeFrame(e){
document.getElementById('myframe').src="mynewpage.htm"
}
//-->
</script>
</head>
<body>
<iframe id="myframe" src="myoriginalpage.htm" style="width:50%">
</body>
Hope this helps,
ajkimoto
you can see my implementation at [anjusevin.com ]
Ah. It seems that IE is calling the function as soon as it sees it, but before the rest of the document loads. We need to put a flag in place that flips to true when the doc is loaded:
<script type="text/javascript">
<!--
//initialize global variable flag to false
var funcFlag=false
function resizeFrame(e){
//check to see if funcFlag is true or not
if (funcFlag==true){
document.getElementById("myframe").src="http://www.ebay.com"
}
}
window.onresize=resizeFrame
//-->
</script>
</head>
<!--when doc finished loading, set flag to true//-->
<body onload="funcFlag=true">
That should do it.
ajkimoto
<html>
<head>
<script type="text/javascript">
<!--
window.onResize=resizeFrame()
//initialize global variable flag to false
var funcFlag=false
function resizeFrame(e)
{
//check to see if funcFlag is true or not
alert("getting there")
if (funcFlag==true)
{
alert("hello")
document.getElementById('secret').src="http://www.anjusevin.com/secret.htm"
document.getElementById('test').src="http://www.amazon.com"
}
}
</script>
</head>
<BODY onLoad="funcFlag=true">
//plain html in here
<iframe id="secret" name="secret" src="http://www.anjusevin.com/secret.htm" height=500 style="width:100%">
<iframe id="test" src="http://www.ebay.com" height=500>
</body></html>