Using Anchors and GET variables
Monday, February 18th, 2008Well in general it is impossible to use them both. So http://www.yourdomain.com/yourpage.php?get=fubar#anchor1 is not going to work in most browsers, so we want to forget about that. I solved this problem with a little javascript workaround and an additional GET varibale. So step one is that your links would have to include a get variable “?a=YourAnchor”. Now we dont use the usual anchor but place a div with the id YourAnchor at the position we want the page to jump to. I use some javascript that is called when the page loads and the looks up the div with the id YourAnchor and scrolls the page to its position.
</pre>
<div id="YourAnchor"></div>
onload="go_to('<?php echo $_GET['a']; ?>')"
//in order to call the function simply place the following code in your body tag
<pre>
note that this is quite insecure though.