Forum Moderators: open

Message Too Old, No Replies

Nested Frame Title

I can't figure out how to get the document title of a nested frame.

         

adni18

11:09 pm on Apr 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Philip Internet Access Explorer 12.0</TITLE>
</HEAD>
<!-- This file must be named index.html and the other frame files linked to it -->
<FRAMESET ROWS="48, *, 0" ID="TOOL">
<FRAME NAME="topfrm" SRC="topbar.htm" scrolling="no" border="1" noresize>
<FRAMESET ID="FSet" COLS="0,*">
<FRAME NAME="fav" SRC="M.htm" noresize>
<FRAME NAME="browseframe" ID="browseframe" SRC="about:home">
</FRAMESET>
<FRAME NAME="address" SRC="Address.html" scrolling="no" border="1" resize="yes">
</FRAMESET>
</HTML>

How do I get the document.title of the "browseframe" frame from the "address" frame? I really need help. Please...

ajkimoto

2:42 pm on Apr 16, 2004 (gmt 0)

10+ Year Member



adni18,

First of all: Welcome to Webmaster World!

As for your question, I can think of two different ways to do it.

One method is to push the title from the document contained in browserframe to the parent window. To do so, add the following code to the head of the html document contained in browserframe:

<script type="text/javascript">
<!--
function setParentTitle(){
var curTitle='My New Title!'
//or var curTitle=document.title if you want to push the actual title
parent.document.title=curTitle
//-->

Then attach the setParentTitle() function to the body load event of the html document contained in browserframe:

<body onload="setParentTitle()">

The other method is to pull the title of the document contained in browserframe from the containing frameset document. To do this, add the following to the head of the frameset html document:

<script type="text/javascript">
<!--
function changeTitleFromFrame(){
var curTitle=window.frames['browseframe'].document.title
document.title=curTitle
}
//-->
</script>

Then attach the changeTitleFromFrame() function to the load event of the browserframe frame in the frameset html document:

<FRAME NAME="browseframe" onload="changeTitleFromFrame()" id="browseframe" SRC="blah.htm">

Hope this helps,

ajkimoto

adni18

1:52 am on Apr 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, but I don't really want the title of browseframe to be in the title of the mainframe to be the title of the browseframe, I need to just make it display it in the frame. And what the thing is is a virtual browser, so I can't edit every page the user is going to be visiting so it has that script on it. What I really need is a way to get the DOM of the browseframe into the topfrm, so I can get its title, write() function, body innerHTML, and so fourth. I can get up all the way to top.browseframe, but when I ask it to alert(top.browseframe.document), it says 'document' in 'top.browseframe' is not specified. :(

ajkimoto

6:04 pm on Apr 19, 2004 (gmt 0)

10+ Year Member



adni18,

I see. So you want to be able to access the DOM of the document contained in browseframe from a script contained in topfrm?

Try putting this in the document contained in topfrm:

<script type="text/javascript">
<!--
function getDOMStuff(){
var curTitle=parent.frames['browseframe'].document.body.title

var curHTML=parent.frames['browseframe'].document.body.innerHTML

alert(curTitle)

alert(curHTML)
}
//-->
</script>

<style type="text/css">

</style>

</head>

<body>
<button onclick="getDOMStuff()">Access DOM of doc in browseframe</button>
</body>

Does this give you what you need?

ajkimoto

adni18

9:22 pm on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Exactly. That is what I tried at first. But just try it on ur computer. With blank frames except for the topframe. It doesn't work.

Rambo Tribble

10:44 pm on Apr 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It sounds like you are saying that browseframe is empty when you're asking for the document it has loaded.

adni18

10:07 pm on Apr 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No! It can have any page in it. But I was saying to test the frameset with 'Page Cannot be displayed' instead of having to make 'fav.html' and so on.