Ok, well mopst people will tell you to use a piece of javascript.
But this is much less useful, than a simple attribute in the <body> tag of your page.
A javascript type defence has many problems
- Someone may disable javascript to get round it
- you are not protected against people pressing the menu button on their keyboard
- you can chnage mouse buttons to right click, and most scripts only protect against button 2
- people with three button mice, often get round these scripts
you said you wanted an alert saying "bad move" or something, so i will give you code to disable the context menu, then to cause the alert, this is most effective.
To cause the context menu to not-apear when someone right clicks on your page, simply, use this in your <body> tag.
CODE
oncontextmenu="return false;"
your body tag may look like this:
CODE
<body bgcolor="112233" onmousedown="coordinates(event)" oncontextmenu="return false;">
Ok, this will not disable the "page" menu in IE 7 ect. I dont think there is a way to disable that, but it will disable the context menu.
Now for the script.
This code will cause an alert to appear, if any mouse button is clicked, other than button one.
CODE
<script type="text/javascript">
function coordinates(event)
{
if (event.button==1)
{
}
else {
alert("bad move");
}
}
</script>
This should be placed in the head section, and run onmousedown.
However, this script will say "bad move" even on click of the middle button, fo people who want to use autoscroll, will not be le to, and will have to scroll manually, with the mouse wheel.
This code, will only say "bad move" if button two is pressed, remember, this is even easier to evade than the previous script.
CODE
<script type="text/javascript">
function coordinates(event)
{
if (event.button==)
{
alert("bad move");
}
else {
}
}
</script>
Here is a sample of what the page could look like:
CODE
<html>
<head>
<script type="text/javascript">
function coordinates(event)
{
if (event.button==1)
{
}
else {
alert("bad move");
}
}
</script>
<title>my Photo Gallery</title>
</head>
<body bgcolor="112233" onmousedown="coordinates(event)" oncontextmenu="return false;">
<p>Content goes here</p>
</body>
</html>
Note that none of the scripts above will cause the alert if the menu buttonis pressed, if you want that to trigger the alert, replace
CODE
oncontextmenu="return false;"
with something like
CODE
oncontextmenu="functionabc()";
Then create a javascript function with that name, that causes an alert like this:
CODE
<script type="text/javascript">
function functionabc()
{
alert("Bad move")
}
</script>
Remember that you cant ever really stop people steeling your code or imagesm, there is always a way, i wont list the ways, but im sure you can imagine.
one great way round this, is simple text.
Simply make sure, you write at the bottom of the page, what people are allowed to use your images/content for, and make sure you put author information in HTML comment tags in your code.
You said you wanted to make a navigation menu, I am happy to help you, but could you provide some more information as to what you want.
(do you want to use images, do you want something to change colour when you hover over it ect.)
Comment/Reply (w/o sign-up)