开发者社区> 问答> 正文

获取子iframe中的元素

screenshot
如何获取子iframe中的元素呢(子iframe中是一个html页面),并进行填充

展开
收起
小旋风柴进 2016-03-19 10:29:33 2026 0
1 条回答
写回答
取消 提交回答
  • 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(); 
    2019-07-17 19:07:34
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载