这篇文章主要介绍了js实现向iframe中表单传值的方法,涉及js针对页面元素及表单属性操作相关实现技巧,需要的朋友可以参考下
本文实例讲述了JS实现向iframe中表单传值的方法。分享给大家供大家参考,具体如下:
给iframe加contentWindow属性后,才能赋值,在IE,firefox测试一切ok.
例如:
页面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>页面b.jsp:
<form name="ExecuteForm" method="post" action=""> <input type="hidden" name="Sql" id="Sql"> <input type="hidden" name="Result" id="Result"> </form>
以上就是JS向iframe中表单传值的实现方法的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号