获取 Iframe内的元素对象
2011-08-12 21:20
190 查看
//这一篇是Javascript,不是Jquery
1,实现javascript重载iframe页面,兼容各浏览器的方法
document.getElementById(FrameID).contentWindow.location.reload(true);
2,其次是获取iframe内的元素并应用
iframe.contentWindow.document.getElementById(id).style.display="block";
3,iframe页面调用父级页面中的函数
parent.dofunction();
关键字:contentWindow与parent
contentWindow 实例
iframe = document.getElementById("frame");
iframe.contentWindow.location = "http://mozilla.org";
iframe.contentWindow.history.back();
说明 http://www-archive.mozilla.org/docs/dom/domref/dom_frame_ref5.html
先整理这些,备录,继续完善。转自:http://www.liuhui.info/article16.html
获取 Iframe内的元素对象
test1.html //转自:/article/4010394.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>
1,实现javascript重载iframe页面,兼容各浏览器的方法
document.getElementById(FrameID).contentWindow.location.reload(true);
2,其次是获取iframe内的元素并应用
iframe.contentWindow.document.getElementById(id).style.display="block";
3,iframe页面调用父级页面中的函数
parent.dofunction();
关键字:contentWindow与parent
contentWindow 实例
iframe = document.getElementById("frame");
iframe.contentWindow.location = "http://mozilla.org";
iframe.contentWindow.history.back();
说明 http://www-archive.mozilla.org/docs/dom/domref/dom_frame_ref5.html
先整理这些,备录,继续完善。转自:http://www.liuhui.info/article16.html
获取 Iframe内的元素对象
test1.html //转自:/article/4010394.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>
相关文章推荐
- iframe中获取父元素的window对象
- 获取iframe节点元素里的document对象
- (转)获取/设置IFRAME内对象元素的几种JS方法
- 【转】获取/设置IFRAME内对象元素的几种JS方法
- 获取/设置IFRAME内对象元素的几种JS方法
- 获取/设置IFRAME内对象元素的几种JS方法
- JS获取/设置iframe内对象元素、文档的几种方法
- 获取/设置IFRAME内对象元素的几种JS方法
- 快速获取/设置iframe内对象元素的几种js实现方法
- ★★ 总结:获取 Iframe内的元素对象,兼容ie、firefox
- JS获取/设置iframe内对象元素、文档的几种方法
- ★★ 总结:获取 Iframe内的元素对象,兼容ie、firefox
- javascript获取iframe框架中页面document对象,获取子页面里面的内容,iframe获取父页面的元素,
- Jquery方式获取iframe页面中的 Dom元素
- jQuery 获取对象 根据属性、内容匹配, 还有表单元素匹配
- js中如何获取另一个IFrame的元素
- javascript 获取iframe元素的方法
- 获取Iframe内部的元素
- 在当前页面获取iframe中的元素
- Js/Jquery获取iframe中的元素 在Iframe中获取父窗体的元素方法