event.preventDefault() function not working in IE

后端 未结 11 2585
栀梦
栀梦 2020-11-22 02:22

Following is my JavaScript (mootools) code:

$(\'orderNowForm\').addEvent(\'submit\', function (event) {
    event.prev         


        
11条回答
  •  别那么骄傲
    2020-11-22 02:57

    Here's a function I've been testing with jquery 1.3.2 and 09-18-2009's nightly build. Let me know your results with it. Everything executes fine on this end in Safari, FF, Opera on OSX. It is exclusively for fixing a problematic IE8 bug, and may have unintended results:

    function ie8SafePreventEvent(e) {
        if (e.preventDefault) {
            e.preventDefault()
        } else {
            e.stop()
        };
    
        e.returnValue = false;
        e.stopPropagation();
    }
    

    Usage:

    $('a').click(function (e) {
        // Execute code here
        ie8SafePreventEvent(e);
        return false;
    })
    

提交回复
热议问题