jquery屏蔽右键菜单
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
javascript屏蔽右键菜单
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu(){
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e){
if (window.Event){
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3){
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
event.stopPropagation();
jQuery阻止默认行为,不阻止事件冒泡
event.preventDefault();
jQuery阻止了默认事件,也阻止了默认行为
return false;
javascript阻止浏览器的默认行为
function stopDefault(e) {
//如果提供了事件对象,则这是一个非IE浏览器
if(e && e.preventDefault) {
//阻止默认浏览器动作(W3C)
e.preventDefault();
} else {
//IE中阻止函数器默认动作的方式
window.event.returnValue = false;
}
return false;
}
javascript停止事件冒泡
function stopBubble(e) {
//如果提供了事件对象,则这是一个非IE浏览器
if(e && e.stopPropagation) {
//因此它支持W3C的stopPropagation()方法
e.stopPropagation();
} else {
//否则,我们需要使用IE的方式来取消事件冒泡
window.event.cancelBubble = true;
}
return false;
}