开发者

Edit contents of an Iframe

How do you edit content of an Iframe which is generated by a javascript? The iframe doesn't have a name. Basically what I want to do it edit开发者_Go百科 some text in the ifrmae and remove the images in it.

Please tell me how it can be done.

Thanks.


If the iFrame is hosted on the same domain, you can access the contents of it. To grab it without any name, id, etc you can use getElementsByTagName. So assuming you only had one iframe on the page:

var iframeElement = document.getElementsByTagName('iframe')[0];
var imageElement = iframeElement.contentDocument.getElementById('myImage');


if there is no name set for the frame you can access it by using

window.frames[0].document ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜