Problem changing frame source with javascript...

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
lidds
Forum Newbie
Posts: 5
Joined: Mon Oct 20, 2003 10:22 am
Location: UK

Problem changing frame source with javascript...

Post by lidds »

I have a HTML page that creates 3 frames, as shown below:

Code: Select all

<!DOCTYPE HTML PUBLIC &quote;-//W3C//DTD HTML 4.01 Transitional//EN&quote;>
<html lang=&quote;en&quote;>
<head>
    <title><!-- Insert your title here --></title>
</head>

<frameset border=&quote;0&quote; rows=&quote;100,100%,40&quote;>
<frame SCROLLING=&quote;NO&quote; noresize=&quote;noresize&quote; name=&quote;header_frame&quote; src=&quote;controlPanelNav.html&quote;>
<frame noresize=&quote;noresize&quote; name=&quote;main_frame&quote; src=&quote;login.html&quote;>
<frame SCROLLING=&quote;NO&quote; noresize=&quote;noresize&quote; name=&quote;footer_frame&quote; src=&quote;footer.html&quote;>
</frameset>
</html>
and within the controlPanelNav.html page which is in the "header_frame" I have a button which is calling a javascript function within the controlPanelNav.html page, all I want to be able to do is change the HTML page displayed in the "main_frame" to another. An example of the code I'm using is below, what am I doing wrong??

Code: Select all

function getNewLocation()
{
	window.main_frame.location = &quote;loggedOut.html&quote;;
}
cheers

Simon
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

It seems you cannot change the value of the target frame without calling a user defined function in the target frame to do the job.

In controlPanelNav.html :

Code: Select all

<input type=&quote;button&quote; onclick=&quote;getNewLocation()&quote;>
<script type=&quote;text/javascript&quote;>
function getNewLocation()
 {
        parent.frames&#1111;'main_frame'].changeLocation('loggedOut.html');
 }
</script>
In login.html :

Code: Select all

<script type=&quote;text/javascript&quote;>
function changeLocation(url)
 {
        window.location = url;
 }
</script>
lidds
Forum Newbie
Posts: 5
Joined: Mon Oct 20, 2003 10:22 am
Location: UK

Post by lidds »

Thanks a lot, works great

cheers

Simon
Post Reply