473,386 Members | 1,757 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,386 software developers and data experts.

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 3107
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4...
12
by: Justin Koivisto | last post by:
I am having a problem with Internet Explorer and javascript on a WYSIWYG editor I am creating. It all works in Mozilla, but IE returns flase for queryCommandEnabled('forecol'). JS isn't my strong...
8
by: '69 Camaro | last post by:
Perhaps I'm Googling for the wrong terms. Does anyone have links to examples of the syntax necessary to read the HTML on another Web page when that HTML is produced from JavaScript using the...
9
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible...
12
by: mistral | last post by:
Can anybody tell me how to get source code of page in iframe? (popup window is clickable image). When I right click on this popup border to view source, i see just as follows <html> <head>...
3
by: Asterbing | last post by:
I want to know the length in pixels of a document embedded in a iframe. The way I go seems to work under IE but not under Firefox (about other browsers I'll see later). Here is my page for...
10
by: AC | last post by:
I had a page that does some event setup on window.onload: function prepEvents() { document.getElementById("menumap_sales").onmouseover = swapMenuSales; // etc } window.onload = prepEvents;
23
by: vunet | last post by:
It is recommended by some sources I found to create IFrames in IE using document.createElement('<iframe src="#">') instead of document.createElement('iframe'). Why and what browser versions to...
8
by: removeps-groups | last post by:
Is there any way to control the space between top of browser or frame and document body? What I have is this: There is a simple file test1.html, and file test.html that displays test1.html in an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.