【发布时间】:2018-02-15 00:23:31
【问题描述】:
我的方案是打开一个包含 iframe 的模式,在 iframe 内有按钮,而 onclick 按钮我需要关闭模式并刷新父窗口
到目前为止我尝试过
父页面:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
// $('iframe').content ().find('#close').click(function(){
// alert('entred');
// });
$('#myModal').contents().find('#close').click(function() {
alert('click');
});
});
</script>
<body>
<div class="container">
<h2>Modal Example</h2>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<iframe src="modal.html"></iframe>
</div>
</div>
</body>
</html>
子页面
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="container">
<p>Hello Session has expeired</p>
<button id="close" type="button">OK</button>
</div>
</body>
</html>
【问题讨论】:
标签: javascript jquery html iframe