TestFrm.htm
<html>
<body>
<p>This is a test page which contains a frame with the frame name<b>test</b>.</p>
<BR><BR>
<input type=text id=input1 name=input1 value="frmparent">
<BR><BR>
<IFRAME id=test name=test src="about:blank"></iframe>
</body>
</html>
Test.hta
<html>
<head>
<HTA:APPLICATION>
<script>
var childwin;
function OpenWindow()
{
childwin = window.open('test.htm','test');
window.setTimeout(SetParent, 1);
}
function SetParent()
{
if (childwin.document.readyState == "complete")
{
childwin.setParent(window);
}
else
window.setTimeout(SetParent, 1);
}
</script>
</head>
<body>
<input type=button value="Open a new window" onclick=OpenWindow()>
<br>
<input type=text id=input1 name=input1 value="hta">
</body>
</html>
Test.htm
<HTML>
<head>
<script>
var newparent;
function setParent(newwin)
{
newparent = newwin;
}
function accessParent()
{
if (newparent!=null && newparent != "undefined")
alert(newparent.input1.value)
else
alert("parent var not set");
}
</script>
</head>
<body>
<input type=button value="Access parent" onclick="alert(window.parent.input1.value)">
<BR><BR>
<input type=button value="Access parent set thru script"
onclick=accessParent()>
</body>
</HTML>
=============================
<HTML>
<HEAD><TITLE>Synchro</TITLE>
<SCRIPT LANGUAGE="JScript">
var right, left;
function init()
{
right = document.frames.frmRight;
left = document.frames.frmLeft;
left.document.body.onscroll = scrollRight;
right.document.body.onscroll = scrollLeft;
}
function scrollLeft()
{
left.document.body.scrollTop = right.document.body.scrollTop;
}
function scrollRight()
{
right.document.body.scrollTop = left.document.body.scrollTop;
}
</SCRIPT>
</HEAD>
<BODY ONLOAD="init()">
<IFRAME ID="frmLeft" SRC="http://msdn.microsoft.com/" STYLE="height:400px;left:10px;position:absolute;top:10px;width:300px">
</IFRAME>
<IFRAME ID="frmRight" SRC="http://msdn.microsoft.com/" STYLE="height:400px;left:320px;position:absolute;top:10px;width:300px">
</IFRAME>
</BODY>
</HTML>
Tidak ada komentar:
Posting Komentar