473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Access iframe DOM

Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?

I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?

This is what I've tried so far without any success:

document.getElementsByTagName("iframe").contentWin dow;
document.getElementsByTagName("iframe").innerHTML;
document.getElementsByTagName("iframe").childNodes[0].innerHTML;
document.getElementsByTagName("iframe").childNodes[0].nodeValue;
document.getElementsByTagName("iframe").documentEl ement;
document.getElementsByTagName("iframe").contentDoc ument.
document.getElementById("testIframe").innerHTML;
document.getElementById("testIframe").childNodes[0].innerHTML;
document.getElementById("testIframe").childNodes[0].nodeValue;

Apr 17 '07 #1
4 32144
Yansky said the following on 4/17/2007 8:13 AM:
Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?

I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?
To manipulate it you have to read it and the reading of it is the
security issue. So no, you can't.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 17 '07 #2
On Apr 17, 10:30 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Yansky said the following on 4/17/2007 8:13 AM:
Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?
I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?

To manipulate it you have to read it and the reading of it is the
security issue. So no, you can't.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Cheers, thanks for the info.

Apr 17 '07 #3
On Apr 17, 5:13 am, Yansky <forbo...@gmail.comwrote:
Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?

I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?

This is what I've tried so far without any success:

document.getElementsByTagName("iframe").contentWin dow;
document.getElementsByTagName("iframe").innerHTML;
document.getElementsByTagName("iframe").childNodes[0].innerHTML;
document.getElementsByTagName("iframe").childNodes[0].nodeValue;
document.getElementsByTagName("iframe").documentEl ement;
document.getElementsByTagName("iframe").contentDoc ument.
document.getElementById("testIframe").innerHTML;
document.getElementById("testIframe").childNodes[0].innerHTML;
document.getElementById("testIframe").childNodes[0].nodeValue;

Saw this someplace
http://xkr.us/articles/dom/iframe-document/
See if this works for you

Apr 23 '07 #4
Mayank wrote:
On Apr 17, 5:13 am, Yansky <forbo...@gmail.comwrote:
>Is it possible to read the DOM of an iframe if the iframe's src is
from another domain?

I realise I can't manipulate the DOM from another domain for security
reasons, but can I access the DOM and just read object's values?

This is what I've tried so far without any success:

document.getElementsByTagName("iframe").contentWi ndow;
document.getElementsByTagName("iframe").innerHTML ;
document.getElementsByTagName("iframe").childNode s[0].innerHTML;
document.getElementsByTagName("iframe").childNode s[0].nodeValue;
document.getElementsByTagName("iframe").documentE lement;
document.getElementsByTagName("iframe").contentDo cument.
document.getElementById("testIframe").innerHTML ;
document.getElementById("testIframe").childNode s[0].innerHTML;
document.getElementById("testIframe").childNode s[0].nodeValue;


Saw this someplace
http://xkr.us/articles/dom/iframe-document/
See if this works for you
Along similar lines:

http://groups.google.com/group/comp....7f310ccaca0c8d

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Apr 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin | last post by:
There seems to be some strange behaviour when trying to get the scrollHeight and scrollTop of an iframe in IE6. I have tried several ways of getting these values when the iframe is written into...
14
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
11
by: f.ruecker | last post by:
Hey Guys, I've done my research for a script that dynamically adjusts the height of the Iframe, but none of the scripts have the features, which I all need. Maybe one of you can help me: 1. The...
1
by: Roy | last post by:
Hi, I have a parent document which has an iframe loaded in it. The iframe has an textfield element. I want to access this textfield element from the parent document. I have tried the following....
3
by: karthickdevi | last post by:
Hi, I have an iframe , say 'iframe01' in my parent document. In the same parent document, i have a div tag and inside the div tag, i have another iframe, say 'iframe02'. Now i want to access...
1
Yanskopolis
by: Yanskopolis | last post by:
Is it possible to read the DOM of an iframe if the iframe's src is from another domain? I realise I can't manipulate the DOM from another domain for security reasons, but can I access the DOM and...
5
by: brad | last post by:
I'll post my code below. My goal is to grab the selected text in an iFrame from javascript (really any way possible). When I highlight text in the iFrame and click the link outside of the iFrame, I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.