0

Possible Duplicate:
Can PHP read the hash portion of the URL?

Hi, I want to go to a part of my web page where a div called bla bla bla is located.

Using this: http://www.mysite.com/mypage#28 I get there.

But I also need that number to process in php. Does the # work like a ? ($_get) as well?

How do I do that otherwise?

Thanks

Community
  • 1
  • 1
Nicolas de Fontenay
  • 2,170
  • 5
  • 26
  • 51

3 Answers3

1

I agree with middaparka, Hash values is a client side values can not be loaded from server side, as Facebook Dynamic Url Loading technique

so you can read it is value from a function, and call that function onload of page to do what you need.

Mhmd
  • 4,989
  • 3
  • 22
  • 29
0

In theory you can use the parse_url function to obtain this, via the PHP_URL_FRAGMENT option. However, in practice I'm pretty sure that there's no guarantee that the browser will pass this information to the server. (i.e.: It won't show up in $_SERVER['REQUEST_URI'], so there's no way to pass this information into parse_url in the first place.)

As such, you'd need to obtain this client-side via JavaScript and forward it to the server. To do this you can use window.location.hash.

e.g.: <script>alert('The hash value is: '+window.location.hash);</script>

John Parker
  • 54,048
  • 11
  • 129
  • 129
0

There is JQuery Plugin "hashchange" using that you can send Ajax request when the hash is changed everytime. You can even bookmark it. http://benalman.com/projects/jquery-hashchange-plugin/

Check out the demo at http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/

Muthu Kumaran
  • 17,682
  • 5
  • 47
  • 70