Page 1 of 1

Problem changing frame source with javascript...

Posted: Thu Jun 09, 2005 5:53 am
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

Posted: Thu Jun 09, 2005 7:47 am
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>

Posted: Thu Jun 09, 2005 8:12 am
by lidds
Thanks a lot, works great

cheers

Simon