Link within a page with GET variable

citizenzen

macrumors 68000
Original poster
Mar 22, 2010
1,546
11,628
I'm creating a form where I display different fields depending on the URL variable that is passed through a link...

<a href="foo.php?a=bar&b=x">Link1</a>
<a href="foo.php?a=bar&b=y">Link2</a>
<a href="foo.php?a=bar&b=z">Link3</a>

These links are a ways down the page, and when clicked, the page jumps to the top because of the new URL. I can "anchor" the page on the links by adding # anywhere in the URL...

<a href="#?a=bar&b=x">Link1</a>

This will keep the page from jumping up, but it breaks my ability to GET the variable. There must be a way to both GET the variable and maintain the focus on the link, but I am too much of a noob to know how.

Anybody help a brother out?
 

citizenzen

macrumors 68000
Original poster
Mar 22, 2010
1,546
11,628
This works... sorta...

<a href="foo.php?a=bar&b=z#x" name="x">Link3</a>

But then it jumps the link to the top of the page. Alternatively, I can name another element somewhere above the link so the jump is less severe. But is there a way to anchor the page so it doesn't jump at all?
 

CANEHDN

macrumors 6502a
Dec 12, 2005
855
0
Eagle Mountain, UT
The only way to have your page do no jump at all is through javascript. Using the html links will move the page a little bit when jumping to the id you've set it to jump to.