글 수 314
iframe에서는 parent로 메인창을 지정하며, 메인창에서는 iframe의 name으로 iframe을 지정합니다.
샘플입니다.
b.html에서는 action과 target을 정확히 지정하세요.
b.html에서 target을 메인페이지로 주시려면 _parent로 하시면 됩니다.
b.html에서의 input값을 a.html에 전달하려면 parent로 찾으시면 됩니다.
<!--a.html-->
<html>
<head>
<script type="text/javascript">
function my_submit() {
self.iframe_html.document.myform.submit();
}
</script>
</head>
<body topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0>
<table width=100% height=100% bgcolor=black border=0 cellspacing=1 cellpadding=0>
<tr align=center bgcolor=white>
<td width=80% height=100>
<div id="parentDiv" align=left>iframe으로부터 메세지를 받는 부분</div>
</td>
<td width=20%>클릭하면 iframe의 form을 submit합니다.<br>
<input type=button value="b.html submit" onclick="my_submit()">
</td>
</tr>
<tr align=center bgcolor=white>
<td colspan=2><iframe name=iframe_html src="b.html" width="100%" height="100%" frameborder=0></iframe></td>
</tr>
</table>
</body>
</html>
<!--b.html-->
<html>
<body>
<form name=myform method=post action="c.html" target="_parent">
아래 input box에 타이핑하면 parent의 div영역에 value를 세팅합니다.<br>
<input type=text name=contents onfocusin="parent.document.all.parentDiv.innerText='지금 내용을 입력하고 있습니다.';" onfocusout="parent.document.all.parentDiv.innerText='';">
</form>
</body>
</html>
샘플입니다.
b.html에서는 action과 target을 정확히 지정하세요.
b.html에서 target을 메인페이지로 주시려면 _parent로 하시면 됩니다.
b.html에서의 input값을 a.html에 전달하려면 parent로 찾으시면 됩니다.
<!--a.html-->
<html>
<head>
<script type="text/javascript">
function my_submit() {
self.iframe_html.document.myform.submit();
}
</script>
</head>
<body topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0>
<table width=100% height=100% bgcolor=black border=0 cellspacing=1 cellpadding=0>
<tr align=center bgcolor=white>
<td width=80% height=100>
<div id="parentDiv" align=left>iframe으로부터 메세지를 받는 부분</div>
</td>
<td width=20%>클릭하면 iframe의 form을 submit합니다.<br>
<input type=button value="b.html submit" onclick="my_submit()">
</td>
</tr>
<tr align=center bgcolor=white>
<td colspan=2><iframe name=iframe_html src="b.html" width="100%" height="100%" frameborder=0></iframe></td>
</tr>
</table>
</body>
</html>
<!--b.html-->
<html>
<body>
<form name=myform method=post action="c.html" target="_parent">
아래 input box에 타이핑하면 parent의 div영역에 value를 세팅합니다.<br>
<input type=text name=contents onfocusin="parent.document.all.parentDiv.innerText='지금 내용을 입력하고 있습니다.';" onfocusout="parent.document.all.parentDiv.innerText='';">
</form>
</body>
</html>