Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blocking shift-click

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
Hi,

Is it possible to add a tag in an HTML document to prevent users from shift-clicking to open a new window?


- Andy
_______________________________
"On a clear disk you can seek forever"
 
no.
You MIGHT be able to capture the click event in Javascript and just do nothing, but why'd you want that?

most people get extremely annoyed by tricks like that (plus they're easy to get around...).
 
Well, here you go.
If you have a use for it, then it's really up to you.

<html>
<head>
<SCRIPT >
function cancelLink() {
if (window.event.srcElement.tagName == &quot;A&quot; && window.event.shiftKey)
window.event.returnValue = false;
}
</SCRIPT>
</HEAD>
<BODY onclick=&quot;cancelLink()&quot;>

<A href=&quot; click for new window (not!)</a>
</body>
</html>

Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
Hi,

Thanks for the code. The reason behind it is I'm using an IE window in an application and I want to intercept shift-clicks so that I can alter the URL before spawning a new window. Like you say, shift-click is a very useful feature, a bit like ctrl-refresh.


- Andy
_______________________________
&quot;On a clear disk you can seek forever&quot;
 
I have to agree with jwenting. Users get comfortable with their browsers and they expect certain things to happen when they interact with it. If you interfere with that expectation then you effectively drive users away, not to mention driving up their level of frustration!

Use this ONLY if your boss demands if from you.

There's always a better way...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top