父页面的代码
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Index</title> <script src="js/jquery-1.9.min.js"></script> </head> <body> <iframe src="form.php" width="800px" height="600px"></iframe> <iframe src="form.php" width="800px" height="600px"></iframe> <iframe src="form.php" width="800px" height="600px"></iframe> <iframe src="form.php" width="800px" height="600px"></iframe> <iframe src="form.php" width="800px" height="600px"></iframe> <iframe src="form.php" width="800px" height="600px"></iframe> <button>aa</button> </body> <script type="text/javascript"> function submitAll(){ var ifms = document.getElementsByTagName(‘iframe‘); for (var i = 0; i < ifms.length; i++) { var win = (ifms[i].contentWindow || ifms[i]); win.submitMe(); } } $("button").click( function () { submitAll() }) </script> </html>
form表单的页面
<script type="text/javascript"> function submitMe(){ document.getElementById(‘testForm‘).submit(); } function submitAll(){ window.parent.submitAll(); } </script>
原文地址:https://www.cnblogs.com/nice2018/p/11393532.html
时间: 2024-12-10 06:55:22