How to manage URL anchor values

Hello, i am doing AJAX aplication and i want to store page state using URL anchors. And in controller i want to get this anchor value.

For example, instead of http://mindmap/notes/index/id/20 i need to have http://mindmap/notes/index#id/20

It is not a problem to add anchor via JS, but i did not found any suitable method to get this value in Yii.

Does Yii have some method for this, or should i parse $_SYSTEM array value to achieve it?


From a server-side perspective, there is no way to get the value of the anchor.

This is because your browser never sends it to the server. I just did some testing on Apache2 with Firefox on windows and this is what I got:

Request Url in Browser: http://localhost/my_script.php#anchor_value

Access Log entry: - - [15/Nov/2009:23:18:48 -0800] "GET /my_script.php HTTP/1.1" 200 2042

PHP $_SERVER[‘REQUEST_URI’]: ‘/my_script.php’

I think the only way to access this anchor value is browser-side with javascript. So if you want to use that to track your location on the site, etc, then you would need to use AJAX to handle all the requests.

killermonk, thanks for answer.

i’ve tested this issue too and i am inspired what browsers kills all info about anchors.

for now i am using ajax to post all anchor data, so it works now =)