Problems getting document title from iframe

A

Adam Lipscombe

Folks,


I want to be able to get title of a document that is presented within an Iframe with the id
"popupFrame". There may be more than 1 instance of the iframe in the page.


This is my code:

var elementCount = document.all("popupFrame").length;
for (var i = 0 ; i < elementCount ; i++)
{
alert("src = " + document.all("popupFrame",i).src);
alert("title = " + document.all("popupFrame",i).document.title);
}


But the wierd thing is that the title is always the title of the document that contains the Iframe.
NOT the title of the document conatined within the Iframe.
At least in IE7 which is all that I have tested it with so far.


Any ideas? What am I missing?


TIA - Adam
 
A

Adam Lipscombe

Sorry I should have added that the Iframe src is always correct.

i.e. alert("src = " + document.all("popupFrame",i).src) displays the correct url but
alert("title = " + document.all("popupFrame",i).document.title) displays the title of the document
that contains the iframe.


Thanks...
 
A

ASM

Adam Lipscombe a écrit :
Folks,


I want to be able to get title of a document that is presented within an
Iframe with the id "popupFrame". There may be more than 1 instance of
the iframe in the page.

You can't have more than *one* element with same *id* !!!


<iframe name="myFrame" src="test.htm" blah></iframe>

<a href="javascript:alert(parent.myFrame.document.title);">my frame
document title said:
This is my code:

var elementCount = document.all("popupFrame").length;
for (var i = 0 ; i < elementCount ; i++)
{
alert("src = " + document.all("popupFrame",i).src);
alert("title = " + document.all("popupFrame",i).document.title);
}

for (var i = 0 ; i < elementCount ; i++)
{
alert("src = " + document.all["popupFrame"].src);
if(document.all("popupFrame").document &&
document.all("popupFrame").document.title)
alert("title = " + document.all("popupFrame").document.title);
}
But the wierd thing is that the title is always the title of the
document that contains the Iframe. NOT the title of the document
conatined within the Iframe.
At least in IE7 which is all that I have tested it with so far.


Any ideas? What am I missing?

document.all("popupFrame") ????
document.all["popupFrame"] ????
 
R

Randy Webb

ASM said the following on 6/16/2007 9:41 PM:
Adam Lipscombe a écrit :

You can't have more than *one* element with same *id* !!!


<iframe name="myFrame" src="test.htm" blah></iframe>

<a href="javascript:alert(parent.myFrame.document.title);">my frame
document title</a>

That is a joke, right?

This is my code:

var elementCount = document.all("popupFrame").length;
for (var i = 0 ; i < elementCount ; i++)
{
alert("src = " + document.all("popupFrame",i).src);
alert("title = " + document.all("popupFrame",i).document.title);
}

for (var i = 0 ; i < elementCount ; i++)
{
alert("src = " + document.all["popupFrame"].src);


document.all?? Shame, shame..... window.frames.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top