try something like (did not test, so it might not work):
var ie5 = (document.all && document.getElementById) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var n6 = (document.getElementById && !document.all) ? true : false;
var n4 = (document.layers) ? true : false;if (ie5) {document.oncontextmenu = function(){return false}}
if (n6) {document.onmouseup = function(e) {if (e.button == 3) return false}}
if(n4) {window.captureEvents(Event.MOUSEDOWN);window.onmousedown =
function(e){if(e.target==document)return false;}}
if (ie4) { document.onmousedown = function(){return false}}
var ie5 = (document.all && document.getElementById) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var n6 = (document.getElementById && !document.all) ? true : false;
var n4 = (document.layers) ? true : false;if (ie5) {document.oncontextmenu = function(){return false}}
if (n6) {document.onmouseup = function(e) {if (e.button == 3) return false}}
if(n4) {window.captureEvents(Event.MOUSEDOWN);window.onmousedown =
function(e){if(e.target==document)return false;}}
if (ie4) { document.onmousedown = function(){return false}}
document.onclick = function (e) { if (e.which == 3) return false };
我也不知道是什么原因这样才行,我看到一些书上写的都是说NS6+是用button,NS4才用which的,我在NS6和NS7上都试过了只能写成这样!还有一点就是,我用document.ondblclick = function () { alert("双击鼠标") }这个事件为什么捕捉不到鼠标双击的呢?在NS6和NS7都是不能,在IE就可以了!
第二,在ns里面ondblclick必须先在body定义过才可以重新赋值。以下在ns6.2,ie5通过:<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function init(){
if (document.all)
document.ondblclick = function () { alert("doubleclick") }
else
window.ondblclick = function () { alert("doubleclick") }
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="init()" ondblclick="">
</BODY>
</HTML>
document.oncontextmenu=new Function("return false")
///////////////////////////////////
function clickIE() {
if (document.all) {
(message);return false;
}
}function clickNS(e) {
if(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3)
{
(message);return false;
}
}
}
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
}
else{
document.onmouseup=clickNS;document.oncontextmenu=clickIE;
}
<SCRIPT LANGUAGE="JavaScript">
<!--
document.oncontextmenu=new Function("return false")
//-->
</SCRIPT>
</BODY>在IE5和ns6.2下面竟然都通过了,天啊