...

View Full Version : DOM and the iframe DOM



ez4me2c3d
02-02-2005, 06:15 AM
Now I have looked over a few articles (http://www.codingforums.com/showthread.php?t=44460&highlight=iframe) on the web about accessing the DOM from an iframe in your current DOM, and I have found them to work...with one exception.

Working with two local documents on my computer i can set one as the parent doc and the other as the iframe src.

the parent doc can correctly tell me how many input elements there are in the iframe doc, and that's just perfect.

However, if I have my parent element on my local computer, and the iframe source is... oh lets say.... http://www.google.com, I cannot get the parent doc to tell me how many tables are in the iframe doc.

why is this?

sample code: (assuming http://www.google.com is the src of your iframe ID=myFrame)
var oFrameDoc = document.getElementById("myFrame").contentDocument;
var oTables = oFrameDoc.getElementsByTagName("table");
alert(oTables.length);

jkd
02-02-2005, 08:03 AM
It's a security restriction placed by the browser itself. If this is for Internet Explorer, then try saving your file as .hta instead of .html. If this is for Gecko-based browsers, then save the file in a subdirectory of "chrome".

ez4me2c3d
02-03-2005, 04:28 AM
i'm not sure how you knew to suggest that but it still didnt work.

in chrome under my firefox folder, i put the main doc and it still didnt reference any info from the DOM in the iframe.

nt though

jkd
02-03-2005, 03:46 PM
You have to access it through a chrome: url.

ez4me2c3d
02-03-2005, 09:50 PM
could you point me to an article that you found that information on? it sounds very interesting. Thanks for all the help thus far. :thumbsup:

liorean
02-03-2005, 10:06 PM
I doubt an article would help you very much - there are not very many articles on the topic. I would instead direct you to developer related sites. Have a look at <http://developer.mozilla.org/>. There's also a nice collection of links on MozDev. <http://www.mozdev.org/docs/>

ez4me2c3d
02-04-2005, 12:13 AM
I doubt an article would help you very much - there are not very many articles on the topic. I would instead direct you to developer related sites. Have a look at <http://developer.mozilla.org/>. There's also a nice collection of links on MozDev. <http://www.mozdev.org/docs/>
i will take a look at those now. thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum