Reputation: 139
It's setup like this:
Parent.html
<html>
<head>
<title>Component Documentation</title>
</head>
<frame src="html\child.html" name="child">
</html>
Child.html
<select name="componentselect" size="24">
When the select box is clicked I need the Parent's title to change. Basically, I want the browser to display the item selected in "componentselect" to appear in the title bar. Setting the document.title in the Child.html isn't working.
Upvotes: 1
Views: 2364
Reputation: 17445
i recommend a Jquery solution, but that won't work from a frame, you might want to consider using divs, there's almost always an alternative to using frames (it might just require more code). Anyway here's the script that works for sure on a self contained html :
<script>
$(document).ready(function($){
$('#componentselect').click(function() {
$(document).attr(’title’, $('#componentselect').val());
});
}
</script>
Upvotes: 0
Reputation: 8541
You can do this by using the top.
or parent.
prefix. It is like your window.
prefix. parent.
will point to the parent's window
object. top.
will point to the main website (in case of using multiple levels of frames). But in some browsers this feature is disabled or limited due to lack of security.
So this will work:
parent.document.title = "I came from outerspace!";
Upvotes: 1
Reputation: 86872
try
function onSelectChange () {
top.document.title = this.options[this.selectedIndex].text;
}
HTML
<select name="componentselect" onchange="onSelectChange()" size="24">
Upvotes: 0
Reputation: 2654
Could do this Javascript function :
<script>
function changeSelect()
{
parent.document.title = this.options[this.selectedIndex];
}
</script>
And the html :
<select name="componentselect" onchange="changeSelect()" size="24">
try parent or top, don't remember wich to use
Upvotes: 0