Forum Moderators: open
When you click on the first flag (German), two frames are supposed to change:
1-the menu in the left-bottom frame. (should change into my german version of the menu: "navi_ger.html")
2-the document that is loaded on the right frame, for example: "cv/MG_CV.html" should change to the corresponding German version of my CV, i.e.:"cv/MG_Lebenslauf.html".
Another example: supposing that the page: my documents ("documents.html") is loaded on the right frame, you click on the German flag and the menu and the "my documents" page change into German menu ("navi_ger.html") and "documents_ger.html"
but my javascript program doesn't do the trick! I don't know what is wrong... Can somebody help?
<html><head><title>language</title>
<script language="JavaScript">
<!--
function change_frames(file1,file2){
parent.frames[2].location.href=file1
parent.frames[3].location.href=file2
}
var mainframe;
mainframe=top.location.href;
function toGerman(){
if (mainframe=="cv/MG_CV.html"¦¦"cv/MG_Lebenslauf.html"¦¦"cv/MG_Hojadevida.html")
{
javascript:change_frames('navi_ger.html','cv/MG_Lebenslauf.html')
};
if (mainframe=="documents.html"¦¦"documents_esp.html"¦¦"documents_ger.html")
{
javascript:change_frames('navi_ger.html','documents_ger.html')
};
if (mainframe=="hobbies.html"¦¦"hobbies_ger.html"¦¦"hobbies_esp.html")
{
javascript:change_frames('navi_ger.html','hobbies_ger.html')
};
if (mainframe=="contact.html"¦¦"kontakt.html"¦¦"Contacto.html")
{
javascript:change_frames('navi_ger.html','kontakt.html')
}
else{
javascript:change_frames('navi_ger.html','home_ger.html')
};
}
//-->
</script>
</head>
<body style="color: rgb(0, 0, 0); background-image: url(203b.jpg);" alink="#000099" link="#000099" vlink="#990099">
<table border="0" cellpadding="0" cellspacing="0" width="180">
<tbody>
<tr> <td><div align="center">
<form>
<input type="image" alt="Deutsche Version" src="index_dateien/deu.gif" border="0" onclick="javascript:toGerman()">
<br><br>
<input type="image" alt="English Version" src="index_dateien/eng.gif" border="0" onclick="javascript:change_frames('navi.html','home.html')"><br><br>
<input type="image" alt="Version Espanola" src="index_dateien/esp.gif" border="0" onclick="javascript:change_frames('navi_esp.html','home_esp.html')">
</form>
</div></td></tr></tbody>
</table>
</body>
</html>
function change_frames refers to "parent" the meaning of which will depend on context of call, eg left is parent of flags. Change change_frames to directly refer to required frames
but I can't figure out how to tell Javascript to look into frame "main" and according to what it finds loaded there, do something!
i.e. if Javascript finds my CV in English in the frame "main", when you click on the German flag, javascript should change the frame "main" into my CV in German.
function change_frames(file1,file2){
parent.frames[2].location.href=file1
parent.frames[3].location.href=file2
}
You should use the <body onload> event in the first page to load the second page into its frame (using location.replace()).
This method means that
a) standard links can be used (no javascript, just a target).
b) the Back button will work correctly.
c) the frames should always be synchronised.
You may need to perform a test before reloading the second page unnecessarily.
Kaled.