Jquery onClientClick执行,然后页面立即回发

Jquery onClientClick执行,然后页面立即回发,jquery,asp.net,frontend,Jquery,Asp.net,Frontend,我有以下代码: functions.js=> function loadPopup() { $("#backgroundPopup").css({ "opacity": "0.7" }); $("#backgroundPopup").fadeIn("slow"); $("#popupContact").fadeIn("slow"); } //disabling popup with jQuery magic! function disable

我有以下代码:

functions.js=>

function loadPopup() {
    $("#backgroundPopup").css({
        "opacity": "0.7"
    });
    $("#backgroundPopup").fadeIn("slow");
    $("#popupContact").fadeIn("slow");
}

//disabling popup with jQuery magic!  
function disablePopup() {
    $("#backgroundPopup").fadeOut("slow");
    $("#popupContact").fadeOut("slow");
}

//centering popup  
function centerPopup() {
    //request data for centering  
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#popupContact").height();
    var popupWidth = $("#popupContact").width();
    //centering  
    $("#popupContact").css({
        "position": "absolute",
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });
    //only need force for IE6  

    $("#backgroundPopup").css({
        "height": windowHeight
    });

}

function no() {
    return false;
    disablePopup();
}

function yea() {
    $('#form1').submit(function () {
        return true;
    })
}

$(function () {
    $("#popupContactClose").bind('click', function () {
        disablePopup();
    });
});

function yeah() {
    $(this).bind('click', function (event) {

        centerPopup();

        loadPopup();

    });
}

。。。以及以下标记:

<body>
    <form id="form1" runat="server">
    <asp:Button ID="btn1" runat="server" OnClientClick="yeah();" Text="Click me!" />
    <div id="popupContact">
        <a onclick="xClick()" id="popupContactClose">x</a>
        <input type="submit" onclick="yea()" value="Yes" />
        <input type="button" onclick="no()" value="No" />
    </div>
    <div id="backgroundPopup">
    </div>
    </form>
</body>
</html>

x

问题是OnClientClick事件调用yea(),div出现,然后立即消失,页面返回。这很奇怪。你能帮我吗?提前谢谢

我认为你需要结束这一事件

onclick="yea();return false;"

可能会这样做。

尽管考虑到您添加到前一个试图回答此问题的人身上的内容,他也可能不会做您想要的事情。在这种情况下,您可能需要在yea()中通过javascript提交表单。我想您是对的。您在此处给出的解决方案无效。它确实会触发post,但是,我的服务器端代码不会执行..:/有什么建议吗?顺便说一句,谢谢你花时间回答我的问题,马克。我认为通常的做法是函数yea(e){/*user code*/e.preventDefault();}onclick=“yea(event);”Pencho,那么你有什么建议?我对javascript和jquery不太熟悉。我正想快点把它捡起来,但我在这里碰到了一堵石墙。。我会感激你的帮助