RSS

Get the body element of an Iframe using Javascript

01 Aug

In javascript, if your document contains an iframe element from any other domain, you cannot get the elemnts inside that source with the normal document.getElementById… For that you have to first get that iframe element using

ifr = document.getElementById(iframeId);

then you can easily get access to the document of that iframe source using,

ifrDoc = ifr.contentWindow.document;

ifrBody = ifrDoc.body,

from this you can get the child nodes using ifrBody.childNodes();

and then match any id and other operations…

 
Leave a comment

Posted by on August 1, 2011 in Javascript

 

Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: