如何隐藏另一个内容的框架。我的意思是:
Parent
Frame F1
Page P1
Frame F2
Page P2
我希望P2使用JQuery的Javascript隐藏帧F1。
答案 0 :(得分:1)
你可以这样做:
<强> iframe的access.html 强>
<html>
<head>
<style type="text/css">
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
<script type="text/javascript">
</script>
</head>
<body>
<iframe src="iframe1.html" id="iframe1"></iframe>
<iframe src="iframe2.html" id="iframe2"></iframe>
</body>
</html>
<强> iframe1.html 强>
<html>
<head>
<style type="text/css">
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
<script type="text/javascript">
</script>
</head>
<body>
<h1>Iframe 1</h1>
</body>
</html>
<强> iframe2.html 强>
<html>
<head>
<style type="text/css">
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js"></script>
<script type="text/javascript">
alert('Hide Iframe 1');
window.parent.document.getElementById('iframe1').style.display = 'none';
</script>
</head>
<body>
<h1>Iframe 2</h1>
</body>
</html>
http://jfcoder.com/test/iframe-access.html
注意强>
这也有效(正如何时指出的那样):
window.parent.document.getElementById('framesetID').rows = "0%,*";