-1

I have a dynamic page in php.I want to extract all the string follwed by # in the URL.The page is a bit like ajax and it doent loads fully just the URL changes.So i need a mechanism as and when the url changes I can capture the string followed by # and do appropriate actions.

eg: index.php#FJDrfjg67

I need

FJDrfjg67

Please Help

anubhava
  • 713,503
  • 59
  • 514
  • 593
log N
  • 899
  • 10
  • 31
  • Also consult as well the javascript reference of your choice, e.g. https://developer.mozilla.org/en-US/docs/Web/API/window.onhashchange – hakre Jul 07 '13 at 15:26

3 Answers3

1

use window.location.hash to get the # content and sent it by ajax

or you can also get this by parse_url()

echo parse_url($url, PHP_URL_FRAGMENT );

its the fragment ( after the hashmark #)

NullPoiиteя
  • 55,099
  • 22
  • 123
  • 139
  • I mean i just want the contents after the hash.The page is made by other author and it changes automatically.I want to make sure that when the url changes i capture the string followed by hash – log N Jul 07 '13 at 06:48
  • how you are changing the url ? – NullPoiиteя Jul 07 '13 at 06:49
  • I am not changing...It gets changed automatically...I dont understand the program.So i just need to detect a change – log N Jul 07 '13 at 06:55
  • well first we need to know how it change and then i can tell you suitable solution – NullPoiиteя Jul 07 '13 at 07:03
0

It's not sent to the browser. You need to use JavaScript and send it using Ajax.

Denis de Bernardy
  • 72,128
  • 12
  • 122
  • 148
0

Browsers don't send part of URI after hash # to server side. You need to do this extraction in browser itself i.e. in Javascript.

Using Javascript you can do:

var hashtag = window.location.hash.replace(/^#/, "");

To get the part of URI after #

You can then send the hashtag variable to server side using a query parameter or in URI itself by appending to the location.href in your javascript.

anubhava
  • 713,503
  • 59
  • 514
  • 593