right and left click

L

Lakshmi Narayanan

hi all,
i have this problem.i want the user of my page to only click the link
with the right mouse button and open a word document using the open in
new window option.if he clicks on the left button i should prompt an
alert message till he clicks the right mouse button
..i just want to write only a FEW lines of code.the code needs to
written inside the <a href></a> tags.can any one help me.

waiting for ur solutions.thanking u in advance.
 
K

kaeli

craynet13 said:
hi all,
i have this problem.i want the user of my page to only click the link
with the right mouse button and open a word document using the open in
new window option.if he clicks on the left button i should prompt an
alert message till he clicks the right mouse button
.i just want to write only a FEW lines of code.the code needs to
written inside the <a href></a> tags.can any one help me.


Why would you want to do such a thing?
This is contrary to all web standards.

If you REALLY feel the need to have it open in a new window, then set
the target.
<a href="whatever.doc" target="_blank">doc</a>

Not that that follows web standards, either.

--
 
E

Evertjan.

Lakshmi Narayanan wrote on 18 feb 2004 in comp.lang.javascript:
i have this problem.i want the user of my page to only click the link
with the right mouse button and open a word document using the open in
new window option.if he clicks on the left button i should prompt an
alert message till he clicks the right mouse button
.i just want to write only a FEW lines of code.the code needs to
written inside the <a href></a> tags.can any one help me.

A bit silly thing to do, I hope never to visit such page!

IE6 tested:

<a href="http://www.cnn.com/"
onclick="alert('Use other mouse button please for: '+
this.href);return false;"
oncontextmenu="location.href=this.href;return false;">
Click me right here</a>
 
C

crazyguy

hi thanx Evertjan
the code works well to my problem.you have given me the solution that i
had been searching for.thanx once again.
 
T

Thomas 'PointedEars' Lahn

kaeli said:
@yahoo.com enlightened us with...
[...] i want the user of my page to only click the link with the
right mouse button and open a word document using the open in new
window option.if he clicks on the left button i should prompt an
alert message till he clicks the right mouse button .[...]

Why would you want to do such a thing? This is contrary to all web
standards.

More, it is contrary to usability standards for Graphical User
Interfaces (GUIs). The "right", i.e. the secondary (if not
configured left-handed), mouse button, is (if present) usually
reserved for the context-sensitive menu in GUIs. For example
Opera is an exception, because it allows one (the secondary by
default) mouse button as dragger button for mouse gestures.
If you REALLY feel the need to have it open in a new window, then set
the target. <a href="whatever.doc" target="_blank">doc</a>

Not that that follows web standards, either.

target="_blank" is valid HTML 4.01 Transitional and valid XHTML 1.0
Transitional. I fail to see a violation of standards here, if I am
understanding you correctly. It is not recommended, though, since
it "breaks" the Back functionality in windowed UAs.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top