PDA

View Full Version : iframe issue



anup.maverick
01-12-2011, 12:16 PM
Hi,

I have 2 iframes on a web page.

In 1st iframe there is a BUTTON, On Button click new pages should open in both the iframes.

I tried using window.parent , but it doesn't work in firefox, chrome, IE 8.

Following is the code :-

Main Page

<body>
<iframe src="1.htm" name="MapFrame"></iframe>
<iframe src="1.htm" name="MapFrame1"></iframe>
</body>
</html>

1st IFrame

<html>
<head>
<title>1 Level</title>
<script type="text/javascript">

function GoToParent()
{
window.parent.document.getElementById("MapFrame"). src = "1.htm";
window.parent.document.getElementById("MapFrame1") .src = "1.htm";
}
</script>
</head>
<body>
<div id="page_effect" style="display:none;">
<Button id="b1" type="button" value="CLICK ME" onClick="GoToParent()" />

</div>
</body>
</html>


Thank You....!!

clueful
01-12-2011, 05:36 PM
Use the error console.

In the real world, document.getElementById expects to be passed an ID.

molendijk
01-13-2011, 03:47 PM
Try:
function GoToParent()
{
top.frames["MapFrame"].location.replace("1.htm");
top.frames["MapFrame1"].location.replace("1.htm");
}
===
Arie Molendijk.