This article mainly introduces the method of JS to transfer values to forms in iframes, involving js related implementation techniques for page elements and form attribute operations. Friends in need can refer to the following
The examples in this article describe JS Implement the method of passing values to the form in the iframe. Share it with everyone for your reference, the details are as follows:
Add the contentWindow attribute to the iframe before assigning the value. Test everything in IE and firefox and everything is ok.
For example:
Page a .jsp
<script language="Javascript"> function ExecuteSql() { var FormObj = document.getElementById("ResultShowFrame").contentWindow; var SqlStr=document.getElementById("sqlcontent").value; if (SqlStr !="") { FormObj.document.getElementById("Sql").value=SqlStr; FormObj.document.getElementById("Result").value='Submit'; FormObj.document.ExecuteForm.submit(); } } </script> <form name="dbcompress" action="?Action=CompressDate" method="post"> <textarea name="sqlcontent" rows="3" wrap="OFF" style="width:100%;" id="sqlcontent"></textarea> <input name="Submit" type="button" onClick="ExecuteSql();" class="Anbut2" value=" 执 行 "> </form> <iframe id="ResultShowFrame" scrolling="yes" src="b.asp" style="width:100%;height:420;" frameborder=1></iframe>
Page b.jsp:
<form name="ExecuteForm" method="post" action=""> <input type="hidden" name="Sql" id="Sql"> <input type="hidden" name="Result" id="Result"> </form>
The above is the detailed content of How to implement JS to pass value to form in iframe. For more information, please follow other related articles on the PHP Chinese website!