/    Sign up×
Community /Pin to ProfileBookmark

Override Ctrl+Click default action

I have this image gallery using Lightbox 2.0, as such each thumbnail must be a click-able link to the image itself — lightbox then displays that into a floating div instead.

So the problem, is that before the images were click-able via lightbox one could ctrl+click the thumbnail to highlight it (via a CSS border). Since the thumbnails are now links, when I ctrl+click them the current browser instead performs a default action, usually opening the image in a new tab.

Is there a way to over ride this default behavior?

Thanks in advance.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallNov 06.2008 — Since some browsers allow any mouse button combinations to be set to do whatever you want them to do, web pages should never try to override those actions unless you want to convince people that your site is broken. Let people use whatever method they usually use to select things when they need to select them.

If your lightbox script is overriding the default actions for that combination to stop it doing what your browser is set to use that combination for then remove the code from the script that is causing the problem.
Copy linkTweet thisAlerts:
@auxoneauthorNov 07.2008 — It makes sense not to override the default browser behavior for the reason you mentioned. I'll have to brainstorm this one further. The problem is I want users to select images by clicking them in some way, but they are links as well so clicking them generally opens them when I just want to trigger some javascript.

Thanks.
×

Success!

Help @auxone 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...