Acess iframe content (in firefox plugin javascript) -
i'm writing firefox plugin open iframe in webpages. want select object in iframe, can't access content:
var iframe = content.document.getelementbyid("mybeautifuliframe"); if (iframe) { var mydiv = iframe.contentdocument.getelementbyid("mydiv"); } erreur : typeerror: iframe.contentdocument undefined
i tryed iframe.content.document.getelemen... , iframe.document.getelemen... same result.
how access iframe dom ? if iframe var type, it's [object xraywrapper [object xulelement]], how access dom objects of xulelement object ?
updated answer:
took @ code , think may have found problem.
you doing:
var iframe = content.document.getelementbyid("muzich_iframe_addcontainer"); if (iframe) { if (iframe.contentdocument.getelementbyid("div")) { this.close_all(); } } muzich_iframe_addcontainer div, not iframe, never has contentdocument. additionally, couldn't make work creating xul elements. had create html div , iframe make work.
here's code:
var htmlns = "http://www.w3.org/1999/xhtml"; var container = document.createelementns(htmlns,'div'); container.setattribute("id", "muzich_iframe_addcontainer"); container.setattribute("style", stylecontainer); //stylecontainer 1 use without background stuff window.content.document.body.appendchild(container); var iframe = document.createelementns(htmlns,'iframe'); iframe.setattribute("id", "muzich_iframe"); iframe.setattribute("style", "width: 100%; height: 100%; " ); iframe.setattribute("src", "http://www.lifehacker.com"); // used example url window.content.document.getelementbyid("muzich_iframe_addcontainer").appendchild(iframe); then, when want check close do:
var iframe = window.content.document.getelementbyid("muzich_iframe"); if (iframe) { if (iframe.contentdocument.getelementbyid("div")) { this.close_all(); } } hope 1 solves you.
Comments
Post a Comment