Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Portland OR
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    setting window.location to new string

    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){
    if(Fname==storyList[i]){
    current= i
    }
    }
    // alert(Pname);
    // alert(foo)
    alert(strt)
    // alert(Fname)



    }


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

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


    }

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

  • #2
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Portland OR
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    as long as the html files are in the same directory, you don't need to specify the full path.

    window.location = storyList[current];
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Portland OR
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    a lot of fuss over nothing

    hey thanks, I guess I was worried about nothing

    -Steward


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •