Hariharbalaji
Hariharbalaji

Reputation: 2578

How to find what link we have clicked?

I my application i am having three links, on clicking the link i need to find which link has been clicked and need to pass some unique information to the next page.

Kindly help

Upvotes: 1

Views: 584

Answers (2)

JeroenEijkhof
JeroenEijkhof

Reputation: 2222

It would be good if you could clarify this a bit. Because there are many ways if solving this without Javascript...

You can either add a paramater to the URL link that is clicked. For instance instead of:

<a href="about.php">About</a>

Use:

<a href="about.php?clicked=about">About</a>

Then simply use that value in using Javascript on the following page by using for instance this script: http://snipplr.com/view/799/get-url-variables/

If you are using a server-side scripting language like PHP you can pick up on what page refered to the page your on.

echo $_SERVER['HTTP_REFERER'] 

There are more examples, just comment on this if you want me to give you more.

Upvotes: 2

SpliFF
SpliFF

Reputation: 38956

Like this <a href="/newpage?some_key=somevalue">link</a>

You'll need to query the parameters on the receiving page, though you could also use a target '#data' and query that.

This site has an example implementation of reading URL parameters

Upvotes: 3

Related Questions