469,578 Members | 1,693 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Problems getting document title from iframe

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
Jun 12 '07 #1
3 2957
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...
Adam Lipscombe wrote:
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
Jun 12 '07 #2
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.tit le);">my frame
document title</a>
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"][i].src);
if(document.all("popupFrame")[i].document &&
document.all("popupFrame")[i].document.title)
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?
document.all("popupFrame")[i] ????
document.all["popupFrame"][i] ????
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jun 17 '07 #3
ASM said the following on 6/16/2007 9:41 PM:
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.tit le);">my frame
document title</a>
That is a joke, right?

<URL: http://jibbering.com/faq/index.html#FAQ4_24>
>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"][i].src);
document.all?? Shame, shame..... window.frames.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 17 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dan Popa | last post: by
12 posts views Thread by mistral | last post: by
3 posts views Thread by Asterbing | last post: by
8 posts views Thread by removeps-groups | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.