1

我有这个用户控制:

function Test1($)
{
    this.Width;
    this.Height;

    this.show = function()
    {
        ///UserCodeRegionStart:[show] (do not remove this comment.)
        var buffer = "..." +
                    "<button onclick=\"alertfuncfora()\"> click </button>" + 
                    "...";

        this.setHtml(buffer);

        ...

        ///UserCodeRegionEnd: (do not remove this comment.)
    }
    ///UserCodeRegionStart:[User Functions] (do not remove this comment.)

    ///UserCodeRegionEnd: (do not remove this comment.):
}

...

function alertfuncfora(){
    alert("ola ola");
}

但是每次单击按钮时,我关闭弹出窗口后都会刷新页面。我不想每次单击按钮时都刷新页面。我该怎么做呢?

4

1 回答 1

3

发生这种情况是因为您的按钮可能位于<form>标签内。

用于return false;防止刷新。

像这样的东西:

<button onclick="alertfuncfora(); return false;"> click </button>

于 2014-08-25T13:33:19.050 回答