firefox disabling selecting

hi i have disable selection by overriding mouse events.. however i can still select evrything using CTRL+A.

is there any work around..?

document.onselectstart = function()
{
return false;
}

document.onmousedown = function()
{
return false;
}

document.onclick = function()
{
return false;
}

document.ondblclick = function()
{
return false;
}
[476 byte] By [Mitsukai] at [2007-11-20 11:14:05]
# 1 Re: firefox disabling selecting
The only way to do that is to disable the A key completely using the event.keyCode.

<body onkeypress="return disableSelectAll(event)">

<script type="text/javascript">
function disableSelectAll(e){
var theKey;
if(window.event){theKey = window.event.keyCode;}
else{theKey = e.which;}

if(theKey == 97){return false;}
else{return true;}
}
</script>
PeejAvery at 2007-11-8 0:43:17 >
# 2 Re: firefox disabling selecting
thanks man, it wont be a problem because i wont have any input boxes on this page :)
its a good idea...

i have another question ..

as u can see i disable all mouse events but my links still work with onclick
<A onclick="navigate('pages/home.html')">Home</A>
but whenever i try to make it possible for this div to select text.. i cant...

<DIV id="content" onselectstart="return true" onmousedown="return true">
Please enable javascript, or upgrade your browser.

arg... to bad this select all in the menu... **** it

i just did -moz-user-select:none; in the css evrywhere except where i want to be able to select text.

thought it wont work on IE, i will have to find a workaround for it :(
Mitsukai at 2007-11-8 0:44:15 >
# 3 Re: firefox disabling selecting
First off, unless you are doing AJAX or something similar, you shouldn't be using JavaScript to navigate. You should just use the href attribute as it is supposed to be used.

Also, remember that <a> tags are able to call JavaScript from the href attribute. I would suggest trying...

<a href="javascript:navigate('pages/home.html')">Home</a>
PeejAvery at 2007-11-8 0:45:15 >
# 4 Re: firefox disabling selecting
i know that peejavery.
when i hover in the menu the whole 'row' of the 'link' is highlighted thus when i click the 'row' it should navigate, also it prevents noscript from opening invalid link.
but when the page loads it must goto home right ? how u do that with a link

i had to make it a link because DIV:hover doesnt work in IE
Mitsukai at 2007-11-8 0:46:15 >
# 5 Re: firefox disabling selecting
i had to make it a link because DIV:hover doesnt work in IE
That is because pseudo-classes only work with certain elements. <a> is one of those.

<noscript>This page requires JavaScript enabled for its functionality.</noscript>

<style type="text/css">
.menu {
color: #000000;
background: #ffffff;
}
.menu:hover {
color: #ffffff;
background: #000000;
}
</style>

<a href="javascript:navigate('pages/home.html')" class="menu">Home</a>
PeejAvery at 2007-11-8 0:47:17 >