WebBuilder101 - Making the web happen!
Need Web Dev software? Here is the place to
Flash Point

How to disable mouse buttons

By Eddy R.
12-14-99

One of the major dilemmas a web builder faces when publishing web work, is how to protect the images and the source code (HTML or any other kind of script) he/she creates from individuals who like to make copies of such work for their own use (without permission).

Although there really isn't a way to keep people from copying one's images and source code, there is something you can do to at least discourage someone (newbies come to mind) who is trying to copy your work.

Disable the mouse buttons

Here is a script (JavaScript) that will allow you to disable the mouse buttons of anyone who views any of your web pages in which this code resides.

Disabling the Right Click button

<script language="javascript">
function click() {
if (event.button==2) {
alert('You can not use mouse buttons here.')
}
}
document.onMouseDown=click
</script>

As always, we start by defining the scripting language we are using
<script language="javascript">

Then we define the function
function click () {

Then we call the event that says: If the right button (which is known as 2) is clicked, pop up and alert window that says "You can't use this button here". Then we use </script> to let the browser know where the script ends.
if (event.button==2) {
alert('You can not use mouse buttons here.')
}
}
document.onMouseDown=click
</script>

Let's go ahead and find out how to disable the Left button as well as how to disable both buttons with the same script.

Let's continue...Next

.

 

More Resources
Scrolling Text
Create Rollovers
Taking and pasting input to your web page
Put the current date on your site
Customize Messages
Change Background colors

Suggested Reading

Beginning Active Server Pages 3.0
JavaScript Bible
Red Hat Linux
Dreamweaver 3.0
HTML Bible



Download WB101 Wallpaper
• Web Builder 101 Wallpaper Get it!.
• Find out how to create your own Wallpaper Teach me!.
Sign up for our Newsletters
• Web Building Sign me Up!.
• Net Alert! Sign me Up!.
Need Help?
• Contact Support Click here.
• E-mail the Webmaster Click Here.
• Search Tips Click Here.

Webbuilder101.com © 1998 - 2003 Copyright and Terms of Use
Send mail to: webmaster@webbuilder101.com

» About » Support

» FAQ » What's New » MyLog

Web Builder 101 Web Builder 101 - Making the Web Happen Web Builder 101 - Making the Web Happen
.