favor
favor

Reputation: 5

PHP anchor question

Is there a way to reload a PHP page when a users clicks a PHP link and then have the page jump to a certain spot on the same page using PHP or JQuery like an HTML anchor?

Here is the PHP link below.

<a href="../index.php?uid=' . $user_id . '&view=member">' . $user_name . '</a>

Upvotes: 0

Views: 107

Answers (1)

Nick Craver
Nick Craver

Reputation: 630379

You can just use a hash link, for example:

<a href="../index.php?uid='.$user_id.'&view=member#section">'.$user_name.'</a>

If in that page you have anything with that ID, say:

<div id="section">

Then it'd scroll down to there, no jQuery or JavaScript needed...this is normal browser behavior. You can read more about it in the HTML4 spec here.

As an example, here's a link to the answer you're reading, see the auto-scroll when you visit it? :)
https://stackoverflow.com/questions/3163053#3163061

Upvotes: 3

Related Questions