JS親ページとサブページの相互変換方法


一、サブページは親ページがwindow.openを通じてイジェクトされた場合、子ページは親ページに値を伝えます。documentの前にwindow.openerを追加すればいいです。例えば:1.親ページコード:
<)xmlns="http://www.w3.org/1999/xhtml"<タイトルレスドキュメントtitle>head"<script lagge="javascript">function tanchu(){    window.open(「Unititled-5」);   }script><body>    <form id=「form 1」name=「form 1」method=「post」action=「」        <label><input type="submit"name="button"id="button"value="提出"            onclick=「tanchu()」/>        label><label><input type="text"name="textfield"id="textfield"/>        label>    form></body></>2.サブページコード:<br><)xmlns="http://www.w3.org/1999/xhtml"<<head><meta http-equiv="Conttent-Type"content="text/htmlcharset=utf-8"/><title>タイトルレスドキュメントtitle>head"<script lagge="javascript">function aa()    window.opener.document.getElementByIdx('textfield').value='123123123';script><body>    <form id=「form 1」name=「form 1」method=「post」action=「」        <label><input type="submit"name="button"id="button"value="提出"            onclick=「aa()」/>        label>    form></body></>二、サブページはiframeフレームのページの場合、サブページは親ページに値を伝えます。documentの前にparentを追加すればいいです。1.親ページコード:<br><)xmlns="http://www.w3.org/1999/xhtml"<<head><meta http-equiv="Conttent-Type"content="text/htmlcharset=utf-8"/><title>タイトルレスドキュメントtitle>head"<body>    <form id=「form 1」name=「form 1」method=「post」action=「」        <label><input type=「text」name=「textfield」id=「textfield」/>        label>        <iframe id="myframe"src="Unititled-3"iframe">    form></body></>2.サブページコード<br><)xmlns="http://www.w3.org/1999/xhtml"<<head><meta http-equiv="Conttent-Type"content="text/htmlcharset=utf-8"/><title>タイトルレスドキュメントtitle>head"<script lagge="javascript">function aa()    var a=parent.document.getElemenntByIdx.value;    alert(a);script><body>    <form id=「form 1」name=「form 1」method=「post」action=「」        <label><input type="submit"name="button"id="button"value="提出"            onClick=「aa()」/>        label>    form></body></>