<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>b</title>
<head>
</head>
<body>
<div class="wrap" id="wrap" style="width:500px;height:500px;background:red;" >
點擊隱藏
</div>
<script type="text/javascript">
document.getElementById("wrap").onclick=function(){
window.parent.document.getElementById("main").style.display="none";
}
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>a</title>
<style type="text/css">
#main{width:300px;height:200px;}
</style>
</head>
<body>
<iframe id="main" src="test.htm" frameborder="no" ></iframe>
</body>
</html>
打開a頁面后,iframe即引入b頁面,點擊iframe中的div,iframe則會隱藏,以實現彈出的iframe關閉效果。
注意:必須在服務器上運行;