Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

citizenzen

macrumors 68000
Original poster
Mar 22, 2010
1,543
11,788
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?
 
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?
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.