现在的位置: 首页 > 综合 > 正文

javascript 阻止事件冒泡 与 浏览器的默认行为

2014年09月05日 ⁄ 综合 ⁄ 共 238字 ⁄ 字号 评论关闭
//功能:停止事件冒泡
function stopBubble(e) {
    if (e && e.stopPropagation)
        e.stopPropagation();
    else
        window.event.cancelBubble = true;
}
//阻止浏览器的默认行为
function stopDefault(e) {
    if (e && e.preventDefault)
        e.preventDefault();
    else
        window.event.returnValue = false;
    return false;
}

抱歉!评论已关闭.