效果如下:
父页面father,弹出层页面son,点击son.html的关闭按钮,关闭弹窗。采用popup.js弹窗插件。
<html>
<head>
<script src="../../jquery-1.8.3.min.js"></script>
<script src="../pop.js"></script>
<script type="text/javascript">
//弹出层
var pop;
function ShowIframe(){
var height = $(window).height();
var width = $(window).width();
pop= new Popup( {
contentType : 1,
isReloadOnClose : false,
scrollType:'yes',
alert:false,
width : 500,
height : 400
});
pop.setContent("contentUrl","son.html");
pop.build();
pop.show();
};
//关闭弹出层
function closeIframe(){
pop.close();
}
</script>
</head>
<body>
<input type="button" value="弹出子页面" οnclick="ShowIframe();"/>
</body>
</html>
son.html:
<html>
<head>
<title>子页面</title>
<script type="text/javascript">
function closeIframe(){
$(window.parent.closeIframe());//调用父页面的方法关闭本页面
}
</script>
</head>
<body>
<input type="button" οnclick="closeIframe();" value="关闭"/>
</body>
</html>