SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    silicon valley
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How does Google Video read a #breadcrumb in a URL?

    I've been trying to figure out how to process the breadcrumb of a URL either server-side with PHP or client-side with Javascript and haven't found anything online that shows how it's done. Just to be clear, by breadcrumb I'm referring to what comes after the # in a URL and causes the browser to jump to the specified anchor.

    I don't think the breadcrumb even gets sent to the server, so I'm guessing Javascript is handling it, but Google Video's code is too obfuscated for my abilities. Here's an example:

    http://video.google.com/videoplay?d...357477938#2m10s

    The "2m10s" after the cross-hatch tells the player to start 2 minutes and 10 seconds into the song. But where is that data getting fed from the URL to? Javascript? Flash? Server-side? Can someone point me to some kind of example or tutorial?

    tia

    (I posted this before in A&U and it was moved to PHP for some reason, dooming it to a life in the middle of the dogpile. I'm really hoping to get an answer, thus the repost.)

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,228
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    URLs

    The fact that the URL doesn't have a file extension (html, php, asp etc) makes me think that Google is processing the HTTP request with (maybe) Apache.
    AFAIK there is no way to send both GET vars and anchor locations at the same time, so I suspect the hash is being used here as a seperator (that and what kind of location is a time instruction) and NOT an anchor location.
    With PHP you can get info from an HTTP request URL like this:
    PHP Code:
    $request_uri $_SERVER["REQUEST_URI"];
    $segments explode("#"$request_uri);
    $number_of_segments count($segments);
    $time_instruction $segments[$number_of_segments-1]; 
    BTW I usually think of navigation links when I hear the term "breadcrumbs", not GET vars.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    silicon valley
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry to dredge this out, but for the sake of future research, this does not work. The client does not seem to send the # or anything after it to the server. I have to conclude that it is done client-side.

    See http://squarehappy.com/testing/bc.php#wtf

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,228
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    parsing urls

    Thanks ak007, a much better way. Using explode has worked for my simple needs so I forgot all about parse-url.
    And the doc page even shows an example of using both GET vars and a location hash. Although I swear that a while back I tried that very syntax and couldn't get it to work.

  6. #6
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Clients do not send URL hashes/fragments to the server; At least they are not supposed to and most don't (I do not know of any off hand that do), so don't count on it being in any of the SERVER variables, because it won't be. It's a client side thing, and if you want it you have to get it with javascript. And that is quite easy as it is the hash property of the location object, i.e, location.hash

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2003
    Location
    silicon valley
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you dreamscape. Simpler than I thought.


Bookmarks

Posting Permissions

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