<html lang="en">
<head>
<title> 弹窗测试 </title>
<meta charset="utf-8"/>
<script src="https://cdn.bootcss.com/jquery/2.0.2/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/layer/3.0.1/layer.min.js"></script>
</head>
<body>
<button id="parentIframe">点击弹出窗口</button>
</body>
</html>
<script>
function refresh() {
location.reload();
}
$('#parentIframe').on('click', function () {
layer.open({
type: 2,
title: '点击弹出窗口',
maxmin: true,
shadeClose: true,
area: ['800px', '520px'],
content: 'http://127.0.0.1/test/layer/form.php' //跳转显示的url
});
});
</script>
///////////////////////////////////显示的提交表单////////////////////////////////////////////////
<?php
if ($_POST) {
echo "<script>parent.parent.layer.closeAll();parent.parent.layer.msg('添加成功,页面正在刷新');parent.parent.setTimeout('refresh()',2000);</script>";
die;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title> 弹窗测试 </title>
<meta charset="utf-8"/>
</head>
<body>
<iframe name="iframe" id="iframe" style="display:none"></iframe>
<form action="#" method="post" target="iframe">
<table border="1">
<tr>
<td>姓名</td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" name="age"/></td>
</tr>
<tr>
<td colspan='2'><input type="submit" value="提交"/>
</td>
</tr>
</table>
</form>
</body>
</html>