Get content of URL after #

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Tyler

    Get content of URL after #

    A simple question:

    If my PHP page is referenced thus: foo.php#bar

    ....what's the best way of getting the contents of the URL
    after the hash - as a string ("bar")?

    Should I get the URL, look for the "#" and then use
    substring()?

    I'd prefer something like:

    $H = $_GET['#']; // reaching...
    --
    __________
    |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.
  • Andy Hassall

    #2
    Re: Get content of URL after #

    On Sun, 12 Oct 2003 19:42:20 GMT, Tim Tyler <tim@tt1lock.or g> wrote:
    [color=blue]
    >A simple question:
    >
    >If my PHP page is referenced thus: foo.php#bar
    >
    >...what's the best way of getting the contents of the URL
    >after the hash - as a string ("bar")?
    >
    >Should I get the URL, look for the "#" and then use
    >substring()?
    >
    >I'd prefer something like:
    >
    >$H = $_GET['#']; // reaching...[/color]

    You can't; it's not passed to the server.

    --
    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

    Comment

    • Tim Tyler

      #3
      Re: Get content of URL after #

      Andy Hassall <andy@andyh.co. uk> wrote or quoted:[color=blue]
      > On Sun, 12 Oct 2003 19:42:20 GMT, Tim Tyler <tim@tt1lock.or g> wrote:[/color]
      [color=blue][color=green]
      >>A simple question:
      >>
      >>If my PHP page is referenced thus: foo.php#bar
      >>
      >>...what's the best way of getting the contents of the URL
      >>after the hash - as a string ("bar")? [...][/color]
      >
      > You can't; it's not passed to the server.[/color]

      So it isn't ;-)

      On reflection, $_SERVER['REQUEST_URI']; gives me close enough to
      what I am after. Thanks for the "#" advice.
      --
      __________
      |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

      Comment

      • Craig Keightley

        #4
        Re: Get content of URL after #

        There is a javascript method that can get the #value

        using location.hash.s lice(1)


        Comment

        • BKDotCom

          #5
          Re: Get content of URL after #

          try parse_url();


          Tim Tyler <tim@tt1lock.or g> wrote in message news:<HMntEK.6t y@bath.ac.uk>.. .[color=blue]
          > A simple question:
          >
          > If my PHP page is referenced thus: foo.php#bar
          >
          > ...what's the best way of getting the contents of the URL
          > after the hash - as a string ("bar")?
          >
          > Should I get the URL, look for the "#" and then use
          > substring()?
          >
          > I'd prefer something like:
          >
          > $H = $_GET['#']; // reaching...[/color]

          Comment

          Working...