View Full Version : setting window.location to new string

06-13-2003, 11:04 PM
I have this script I wrote to check the current URL, and advance the page to the next URL in an array when needed.

I am trying to just have the file names in the array and set the rest of the path in a seperate variable. The script needs to determine the path, because this site will likely be moving to different URLs.

the problem: when I explicitly state the path I need it works, when I use code to determine the path It adds an "undefined" into the URL that causes a 404 error. Any adea what I have done wrong?

Thanks in advance- I am new to this be gentle.

var storyList = new Array ("Fre_01.html","Fre_02.html","Fre_03.html","Fre_04.html","Fre_05.html","Fre_06.html","Fre_07.html","Fre_08.html","Fre_09.html","Fre_10.html","Fre_11.html","Fre_12.html");
var current;
var strt
function findMe(){
var Pname = window.location.pathname;
var foo = Pname.lastIndexOf("/");
var Fname = Pname.substr(foo+1);

//the part below is giving me touble

var addr = window.location.href
var bar = addr.lastIndexOf("/");
var strt = addr.substring(0,bar+1)
// end of trouble

for (i in storyList){
current= i
// alert(Pname);
// alert(foo)
// alert(Fname)


// var strt = "http://www.thresholdstudio.com/studio/BLC/website/story/"

function goNext() {
window.location = strt+storyList[current];


function goPrev() {
window.location = strt+ storyList[current];

06-14-2003, 02:24 AM

06-16-2003, 04:44 AM
as long as the html files are in the same directory, you don't need to specify the full path.

window.location = storyList[current];

06-16-2003, 05:53 PM
hey thanks, I guess I was worried about nothing