
1、你取得iframe的document的前提为这个iframe的地址是你域内的页面,
比如你设src为百度,取这个iframe的document时就会报拒绝访问的错误
2、我试过了 documentgetElementById('myf')contentWindowdocument 在ie与谷歌都行的
3、documentframes('iframename')document 这个方法只能在ie下面取得到
4、用火狐的firebug看看吧,有什么错都会显示出来,莫名其妙的事情什么时候都可能发生,
有时我直接取取window都报undefined
//1、格式:
windowframes["iframe的name值"]documenttitle;
//实例:
windowframes["ifm"]documenttitle;
//2、格式:
var obj=documentgetElementById("iframe的name")contentWindow;
var ifmObj=objdocumenttitle;
//实例:
var obj=documentgetElementById("ifm")contentWindow;
var ifmObj=objdocumenttitle;
//3、格式:
windowparentdocumentgetElementById("父窗口的元素ID")title;
//实例:
windowparentdocumentgetElementById("ifm")title;
//jquery在父窗口中获取iframe中的元素
//1、格式:
$("#iframe的ID")contents()attr("title");//jquery 方法1
//实例:
$("#ifm")contents()attr("title");//jquery 方法1
//2、格式:
$(selector, windowtopdocument);; //jquery 方法2
//实例:
$(document, windowtopdocument)attr("title");//jquery 方法2
//类似的方法
$(selector, windowtopdocument);
$(selector, windowopenerdocument);
$(selector, windowtopframes[0]document);
以上就是关于jquery如何获取iframe的document对象全部的内容,包括:jquery如何获取iframe的document对象、jquery在父页面获取iframe子页面的title,怎么获取、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)