471,336 Members | 1,062 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

Disabling shift click

I want to disable right click in my application.Here are my requirements.

1. I don't what to turn off shift click for the page. I want to turn it off for specific links.
2. I want shift-click to be replaced with a regular click. Meaning, when the user shift-clicks the link they will be taken to the "HREF" within the current browser window and NOT open up a new window.

I did find a script that does something close to what I want, but it fails to meet all of the criteria above... I'll list it below so someone doesn't waste their time providing it as a solution....

Expand|Select|Wrap|Line Numbers
  1. function mouseDown(e) 
  2. {
  3. var shiftPressed=0;
  4. if (parseInt(navigator.appVersion)>3) 
  5. {
  6. if (navigator.appName=="Netscape")
  7. shiftPressed=(e.modifiers-0>3);
  8. else 
  9. shiftPressed=event.shiftKey;
  10.  
  11. if (shiftPressed) 
  12. {
  13. alert ('Shift-click is disabled.')
  14. return false;
  15. }
  16. }
  17.  
  18. return true;
  19. }
  20.  
  21. if (parseInt(navigator.appVersion)>3) 
  22. {
  23. document.onmousedown = mouseDown;
  24.  
  25. if (navigator.appName=="Netscape") 
  26. document.captureEvents(Event.MOUSEDOWN);
  27. }
  28.  
  29.  
Thanks in advance
Feb 8 '06 #1
3 5310
I want to disable right click in my application.Here are my requirements.

1. I don't what to turn off shift click for the page. I want to turn it off for specific links.
2. I want shift-click to be replaced with a regular click. Meaning, when the user shift-clicks the link they will be taken to the "HREF" within the current browser window and NOT open up a new window.

I did find a script that does something close to what I want, but it fails to meet all of the criteria above... I'll list it below so someone doesn't waste their time providing it as a solution....

Expand|Select|Wrap|Line Numbers
  1. function mouseDown(e) 
  2. {
  3. var shiftPressed=0;
  4. if (parseInt(navigator.appVersion)>3) 
  5. {
  6. if (navigator.appName=="Netscape")
  7. shiftPressed=(e.modifiers-0>3);
  8. else 
  9. shiftPressed=event.shiftKey;
  10.  
  11. if (shiftPressed) 
  12. {
  13. alert ('Shift-click is disabled.')
  14. return false;
  15. }
  16. }
  17.  
  18. return true;
  19. }
  20.  
  21. if (parseInt(navigator.appVersion)>3) 
  22. {
  23. document.onmousedown = mouseDown;
  24.  
  25. if (navigator.appName=="Netscape") 
  26. document.captureEvents(Event.MOUSEDOWN);
  27. }
Thanks in advance
Feb 8 '06 #2
ronverdonk
4,258 Expert 4TB
Be sure that there is NO way you can hide your page from someone who is set on knowing what it is! You can only do that for the casual visitor.

Since the HTML stuff (and included Javascript) is client-side at thus running on his/her PC, he/she can always get to it.
You can try to make it very difficult, but there is no preventing a determined user from getting at client-side code. What you can do is use as much server-side code as possible.

Ronald :cool:
Jul 20 '06 #3
iam_clint
1,208 Expert 1GB
I do not believe are you are going to beable to do what your trying..

Shift click is a built in function in IE and other Browsers.. If i figure anything out on it though i will post but i highly doubt its going to work.
Aug 1 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

20 posts views Thread by dukeleto | last post: by
7 posts views Thread by Paul Cooper | last post: by
1 post views Thread by David Hearn | last post: by
5 posts views Thread by Joja | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.