/    Sign up×
Community /Pin to ProfileBookmark

document.title and framesets not working

Scenario: I have a frameset with two frames, “headFrame” and “contentFrame”.

Project: headFrame is static with the navigation for the site. It also has a space to display the current page’s title. This title should be generated dynamically by “reading” the document.title property from contentFrame.

Result: My first attempt was to write:

<script language = “javascript”>
document.write(parent.contentFrame.document.title)
</script>

but nothing was displayed. I assume that it has to do with the fact that the script is running before contentFrame is generated.

Is there a better way to dinamycally generate text reading other frame’s attributes or properties?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@ExuroJan 19.2004 — Maybe instead of having the headFrame read from the contentFrame, you could have the contentFrame write to the headFrame? That would probably eliminate your problem of the script running before the contentFrame was loaded...
Copy linkTweet thisAlerts:
@vmarthirialauthorJan 19.2004 — I thought about that possibility but I faced two limitations (surely because of my scripting shortcomings), the first one was how to point to an specific area (a table, maybe) in headFrame so the text is displayed correctly, and second, maybe I could use a variable, but, again, how can a variable be shared between two frames?
Copy linkTweet thisAlerts:
@Khalid_AliJan 19.2004 — add the following in the frameset page in hte head section above the frames code

<script type="text/javascript">

function changeTitle(){

document.title="New Title";

}

changeTitle();

</script>
Copy linkTweet thisAlerts:
@vmarthirialauthorJan 19.2004 — I thinks there is a confussion regarding what I call Title and document.title. I don't want to change, dynamically the document.title property of any document, instead, I need to "read" this document.title from the contentFrame so I can generate (and display via document.write) a headline in big letter on headFrame so it looks like the document's main title.
Copy linkTweet thisAlerts:
@ExuroJan 21.2004 — Let's say that this was in the headFrame:

[FONT=courier new]<h1 id="header"></h1>[/FONT]

And this is in the contentFrame:

[FONT=courier new]<script type="text/javascript">

<!--

parent.frames['headFrame'].getElementById('header').innerHTML="Some text for the header!";

//-->

</script>[/FONT]

I think that should work...
Copy linkTweet thisAlerts:
@fredmvJan 24.2004 — [i]Originally posted by Exuro [/i]

[B]parent.frames['headFrame'].[b][color=red]document.[/color][/b]getElementById('header').innerHTML="Some text for the header!"; [/B][/QUOTE]
×

Success!

Help @vmarthirial spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...