#1
  1. No Profile Picture
    http://stealthwd.ca
    Devshed Novice (500 - 999 posts)

    Join Date
    Dec 2005
    Posts
    706
    Rep Power
    203

    Window.location troubles


    To make a long story short when I do a redirect like this...

    Code:
    if(window.location.hash.length > 0){
    	window.location = "http://" + "<?php echo $_SERVER['HTTP_HOST']; ?>" + "/" + window.location.hash;
    }
    it goes there, but on the refresh php can't see what was appeneded with the window.location.hash, so its like I'm going to

    Code:
    window.location = "http://" + "<?php echo $_SERVER['HTTP_HOST']; ?>
    "

    thoughts, ideas?

    if I got to that generated URL, without the redirect, it works fine.

    please and thanks
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,105
    Rep Power
    4306
    The hash (also known as the "fragment identifier") is not sent to the server. It's only used on the client side.

    Perhaps you should look into setting up a hash-bang system like that Twitter uses. I recommend you read these:
    Broken Links
    Gawker Learns the Hard Way Why ‘Hash-Bang’ URLs are Evil
    Hash URIs
    URL Design
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. No Profile Picture
    http://stealthwd.ca
    Devshed Novice (500 - 999 posts)

    Join Date
    Dec 2005
    Posts
    706
    Rep Power
    203
    Thanks for the reply. If you look at the code again you'll see I'm not actually passing the hash, I'm replace the hash with a "/"
  6. #4
  7. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,105
    Rep Power
    4306
    But the location.hash property includes the "#" character.

    Code:
    if(window.location.hash.length > 0){
    	window.location = "http://" + "<?php echo $_SERVER['HTTP_HOST']; ?>" + "/" + window.location.hash.slice(1);
    }

    Comments on this post

    • Dameon51 agrees : thanks! that was a part of the problem, also my history library was causing me issues too, but this helped as well
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo