Ignored anchors in the url query?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there,

I have a guestbook on my site, and it gets opened
in a frame. Every message in the page has it's own
anchor according to the message-number.

Now i've made this thing that i can request the url
in the frame by calling the frameset (index.php)
like this --> index.php?interactive/guestbook/
I detect it with $_SERVER["QUERY_STRING"]

But when i want to call a certain message of the GB,
e.g. message 119, index.php?interactive/guestbook/index.php#119
it doesn't work. the $_SERVER["QUERY_STRING"] seems to
completely ignore the '#' character and anything behind it.

Can it be solved and how?

Thanks a lot!

Greetings Knoak

Re: Ignored anchors in the url query?

knoak wrote:
Quoted text here. Click to load it

That's because anchors have no meaning regarding the retrieval of a page on
a server and are parsed by the browser only.

You can solve this by using another character to identify the anchor and
write a piece of javascript to jump to the desired anchor:


if (isset($_SERVER['QUERY_STRING'])) {
 // Location of the page
 $location = strtok($_SERVER['QUERY_STRING'], ";");

 // Generate a piece of script to jump to the desired anchor
 if ($anchor = strtok(";")) {
  print "<script>";
  print "window.onload = function () { location = '$location#$anchor'; }";
  print "</script>";

<a href="index.php?interactive/guestbook/index.php;119">klik</a>

for ($i = 0; $i < 500; $i++) print "<br />\n";

<a name="119">Hello</a>


Site Timeline