获取 Iframe内的元素对象
时间:2010-07-18 来源:fkshl
test1.html
<html>
<head>
<script>
function t(){
var dd = document.all('test2').contentWindow.document;
dd.getElementById('my').style.display='none';
}
function getImage(paht)
{
var dd = document.all('test2').contentWindow.document;
dd.getElementById('covertImage').src=paht;
}
</script>
</head>
<body >
<input type="button" value="test" onClick="t();"/>
<input type="button" value="image1" onClick="getImage('1.jpg')"/>
<input type="button" value="image2" onClick="getImage('2.jpg')"/>
<input type="button" value="image3" onClick="getImage('3.jpg')"/>
<input type="button" value="image4" onClick="getImage('4.jpg')"/>
<iframe id="test2" name="test2" src="test2.html" frameborder="0" ></iframe>
</body>
</html>
test2.html
<html>
<head>
</head>
<body>
<div id="my" name="my">
测试一下,父窗体可以把我隐藏掉!!!!!!!!
</div>
<img src="" id="covertImage"/>
</body>
</html>
<html>
<head>
<script>
function t(){
var dd = document.all('test2').contentWindow.document;
dd.getElementById('my').style.display='none';
}
function getImage(paht)
{
var dd = document.all('test2').contentWindow.document;
dd.getElementById('covertImage').src=paht;
}
</script>
</head>
<body >
<input type="button" value="test" onClick="t();"/>
<input type="button" value="image1" onClick="getImage('1.jpg')"/>
<input type="button" value="image2" onClick="getImage('2.jpg')"/>
<input type="button" value="image3" onClick="getImage('3.jpg')"/>
<input type="button" value="image4" onClick="getImage('4.jpg')"/>
<iframe id="test2" name="test2" src="test2.html" frameborder="0" ></iframe>
</body>
</html>
test2.html
<html>
<head>
</head>
<body>
<div id="my" name="my">
测试一下,父窗体可以把我隐藏掉!!!!!!!!
</div>
<img src="" id="covertImage"/>
</body>
</html>
相关阅读 更多 +