Zifnab
07-01-2003, 12:49 PM
Below is the first function(s) I've made in JavaScript completely from scratch, and it doesn't work. The error I get from this(these) function(s) in Mozilla's JS debugger is that "locArray" is undefined. There might be more errors, but for now the debugger doesn't show any more:
function changeLang()
{
menuhref = parent.menuBar.location.href;
parent.menuBar.location.href=setMain(menuhref);
toplhref = parent.topL.location.href;
parent.topL.location.href=setMain(toplhref);
foothref = parent.footer.location.href;
parent.footer.location.href=setMain(foothref);
mainhref = parent.mainCon.location.href;
parent.mainCon.location.href=setMain(mainhref);
};
function setMain(pagelink)
{
locArray = pagelink.split("/");
last = locArray.length - 1;
oldLoc = locArray[locArray.length - 1];
document.write(oldLoc);
if (locArray[last].charAt(0) = "s")
{
lang = "e";
}
else
{
lang = "s";
}
newLoc = lang + locArray[last].substr(1); return newLoc;
};
This JS gets loaded into the HTML through:
<script language="JavaScript1.2" src="langSwap.js"></script>
And is obviously in the file langSwap.js...
The link that's supposed to make this go off is:
<a href="javascript:changeLang()"><anImageHere></a>
What this function is supposed to do is:
1) get the path names to the files in the different frames
2) modify the file names depending on their current name (ie. change first letter from "e" to "s" or viceversa)
3) load the "new" pages in those frames...
I've been looking at Netscape's Devpage JavaScript-Manuals and so on but haven't managed to find what is wrong with this script... if anyone could help me out it'd be much appreciated.
function changeLang()
{
menuhref = parent.menuBar.location.href;
parent.menuBar.location.href=setMain(menuhref);
toplhref = parent.topL.location.href;
parent.topL.location.href=setMain(toplhref);
foothref = parent.footer.location.href;
parent.footer.location.href=setMain(foothref);
mainhref = parent.mainCon.location.href;
parent.mainCon.location.href=setMain(mainhref);
};
function setMain(pagelink)
{
locArray = pagelink.split("/");
last = locArray.length - 1;
oldLoc = locArray[locArray.length - 1];
document.write(oldLoc);
if (locArray[last].charAt(0) = "s")
{
lang = "e";
}
else
{
lang = "s";
}
newLoc = lang + locArray[last].substr(1); return newLoc;
};
This JS gets loaded into the HTML through:
<script language="JavaScript1.2" src="langSwap.js"></script>
And is obviously in the file langSwap.js...
The link that's supposed to make this go off is:
<a href="javascript:changeLang()"><anImageHere></a>
What this function is supposed to do is:
1) get the path names to the files in the different frames
2) modify the file names depending on their current name (ie. change first letter from "e" to "s" or viceversa)
3) load the "new" pages in those frames...
I've been looking at Netscape's Devpage JavaScript-Manuals and so on but haven't managed to find what is wrong with this script... if anyone could help me out it'd be much appreciated.