/    Sign up×
Community /Pin to ProfileBookmark

Detecting "Link click" Event

I have a javascript function which blairs the “body” and opens (visibles) a div which shows “Loading Page…” text.
Now, I want to add it to all of the controls that are clickable, like links and images and when Select value is changed. Now how can I do that?
I tried to use Unload event though it wont work. When I use onClick event in the body tag it does work though it also triggers the function when the user clicks on an empty spot on the page. Can I use the onClick event in BODY though somehow check if the user has clicked a link and not just clicked the mouse anywhere?

NOTE: I can’t add the onClick event to each link because I user ASP.NET and add most of the controls dynamically on runtime, and adding with ASP.NET recoursively is not reliable as I checked.

Please help, Thanks in advance,
Sagi Rodin.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@CharlesSep 17.2006 — onload = function () {
var l, i = 0
while (l = document.links[i++])) {
l.onclick = function () {alert ('link')}
}
}
Copy linkTweet thisAlerts:
@sagirodinauthorSep 17.2006 — Hi,

I get an error when trying to add this code you gave me. Where exactly should I add it? and will it work on other controls which are not links...? Like images and etc'

Thanks,

Sagi
Copy linkTweet thisAlerts:
@konithomimoSep 17.2006 — add it between your script tags
×

Success!

Help @sagirodin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...