faqts : Computers : Programming : Languages : JavaScript : Links

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 8 people (63%) answered Yes
Recently 5 of 8 people (63%) answered Yes

Entry

how to differciate which link clicked in a web page?

Jan 28th, 2003 00:03
Klaus Bolwin, Kulandaivadivel Duraisamy,


You can do it like this:
<html>
<head>
<title>xxx</title>
<script language="JavaScript">
function tuwas(a) {alert(a.id);}
</script>
</head>
<body>
<a href="file1.html" id="a1" onclick="tuwas(this)">text1</a><br />
<a href="file2.html" id="a2" onclick="tuwas(this)">text2</a><br />
<a href="file3.html" id="a3" onclick="tuwas(this)">text3</a><br />
<a href="file4.html" id="a4" onclick="tuwas(this)">text4</a><br />
<a href="file5.html" id="a5" onclick="tuwas(this)">text5</a><br />
<a href="file6.html" id="a6" onclick="tuwas(this)">text6</a><br />
<a href="file7.html" id="a7" onclick="tuwas(this)">text7</a><br />
<a href="file8.html" id="a8" onclick="tuwas(this)">text8</a><br />
</body>
</html>