Firefox兼容的JavaScript回车

if (document.addEventListener) {
    document.addEventListener("keypress", fireFoxHandler, true);
} else {
    document.attachEvent("onkeypress", ieHandler);
}

function fireFoxHandler(evt) {
    if (evt.keyCode == 13) {
        doFilter();
    }
}

function ieHandler(evt) {
    if (evt.keyCode == 13) {
        doFilter();
    }
}

function doFilter() {
    ////
    $j("#page-form").submit();
}
 

你可能感兴趣的:(JavaScript)