document.oncontextmenu = function(){return false;};
or the new Function way in your script. That'll work for most browsers you'll get coming to your site (well, I presume it'll work in IE, but I'm not going waste my time actually testing something like this
)
But, as everyone else has said, why do you want to do this? It's incredibly simple to get round and just pisses the hell out of people who want to use the context menu for something else.
And anyway, there's nothing really wrong with the script you posted being that many lines - it's just browser checking for the people who haven't upgraded in the last 7+ years...
Oh yeah, and of course you can put that in an external JS file and just link it. It's good practice to do that for all scripts you're going to use teh web.
or the new Function way in your script. That'll work for most browsers you'll get coming to your site (well, I presume it'll work in IE, but I'm not going waste my time actually testing something like this
)But, as everyone else has said, why do you want to do this? It's incredibly simple to get round and just pisses the hell out of people who want to use the context menu for something else.
And anyway, there's nothing really wrong with the script you posted being that many lines - it's just browser checking for the people who haven't upgraded in the last 7+ years...
Oh yeah, and of course you can put that in an external JS file and just link it. It's good practice to do that for all scripts you're going to use teh web.