tags:

views:

47

answers:

2

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 some text in the ifrmae and remove the images in it.

Please tell me how it can be done.

Thanks.

A: 

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');
mopoke
A: 

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

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