如何隐藏另一帧的内容。我的意思是:如何隐藏另一帧的子帧的帧?
Parent
Frame F1
Page P1
Frame F2
Page P2
我从P2想隐瞒使用JQuery的JavaScript中的帧F1。
如何隐藏另一帧的内容。我的意思是:如何隐藏另一帧的子帧的帧?
Parent
Frame F1
Page P1
Frame F2
Page P2
我从P2想隐瞒使用JQuery的JavaScript中的帧F1。
你可以这样做:
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%,*";
你的意思是你怎么从内P2的JS进入F1? – 2011-05-29 14:15:31
是的,我想隐藏只访问它 – Jose 2011-05-29 14:15:55
所有这些帧来自同一个域? – 2011-05-29 14:18:24