By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,576 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,576 IT Pros & Developers. It's quick & easy.

Disable left mouse button with out alert message

P: 49
Hai guys,

I want the the code to disable Left Mouse button with out Alert message.

Below code i am having

Expand|Select|Wrap|Line Numbers
  1. <!-- This code is for disableing left click-->
  2. <script language="javascript">
  3. function noClick() {
  4. if (event.button==1) {
  5. alert('You cannot click')
  6. }
  7. }
  8. document.onmousedown=noClick
  9. </script>
  10.  
i am having the above code with alert mesage.so can any one disable the alert message form the above code ? or send some other code for disable left mouse button with out alert message.
It's urgent.

Thanks,
Nagesh.
Sep 12 '08 #1
Share this Question
Share on Google+
3 Replies


Ferris
100+
P: 101
Hi
[HTML]
<script language="javascript">
function noClick() {
if (event.button==1) {
return false;
alert('You cannot click');
}
}
document.onmousedown=noClick;
</script>
[/HTML]

you mean this? or you want to forbidden user click in your web page?
Sep 12 '08 #2

acoder
Expert Mod 15k+
P: 16,027
The code is not cross-browser. 'event' is not global in most browsers.

Try something like this instead (right mouse detect).

The language attribute is deprecated. Use type="text/javascript" instead.
Sep 12 '08 #3

P: 49
The code is not cross-browser. 'event' is not global in most browsers.

Try something like this instead (right mouse detect).

The language attribute is deprecated. Use type="text/javascript" instead.

Thanks for ur reply.
Sep 12 '08 #4

Post your reply

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