Click to See Complete Forum and Search --> : accessing links within an iframe


medc77
12-14-2005, 02:47 AM
Hi,

I have an html document which:

A) contains an iframe: "iframe1"
B) opens a pop-up window: "popup1"

How can I access the iframe's link object from the popup window.

I've tried everything. The closest I've come to it is placing the code below in the popup1 window:


var iframelinks = opener.document.getElementById('iframe1');
var iframelinks2 = iframelinks.document.links[0].href;
document.write(iframelinks2);


Using my amateur logic, iframelinks2 should be referencing a link within the iframe, but instead it references a link in the main parent window.

any help is appreciated. thanks.

Kor
12-14-2005, 03:02 AM
var iframelinks = opener.document.getElementById('iframe1').contentWindow.document.getElementsByTagName('a')[0].getAttribute('href');

medc77
12-14-2005, 03:07 AM
perfect!!!!!

thanks!!!!!!!!!!! :D