Mindon.IDEA

Air off, Mind on ~ / Javascript+Golang, Sci, Health… /

Javascript之取消

BlogMS original blog key: 1000124479, blog id: airoff History stat: 浏览/评论:200/0 , 日期:2004年12月22日 17:12

// cancel pop menu

function cancelkey(e) {

if(document.all) event.returnValue = false; return false;

}

document.oncontextmenu = cancelkey;

// cancel shift-click/enter open new

function cancelNew(e) {

if(document.all) {

if(event.shiftKey)

if(event.keyCode == "13" || event.type=="click") return false;

} else {

if(e.shiftKey)

if(e.keyCode == "13" || e.type=="click") return false;

}

return true;

}

document.onkeypress = cancelNew;

//cancel select

document.onselectstart = function(){ if(event.srcElement.tagName != "INPUT" && event.srcElement.tagName != "TEXTAREA") return false; return true;}

//cancel drag

document.ondragstart = function(){ if(event.srcElement.tagName != "INPUT" && event.srcElement.tagName != "TEXTAREA") return false; return true;}

Comments