最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AVoid Postback on OnClick Event - Stack Overflow

programmeradmin0浏览0评论

I have a Javascript function

show()
{
alert("hello");
}

which runs on ASP Button OnClick Event.

When I click the button of alert message box showing "hello", postback occurs. Is there any way I cant prevent this postback?

I have a Javascript function

show()
{
alert("hello");
}

which runs on ASP Button OnClick Event.

When I click the button of alert message box showing "hello", postback occurs. Is there any way I cant prevent this postback?

Share Improve this question edited Sep 25, 2012 at 18:46 Gonzalo.- 12.7k5 gold badges52 silver badges83 bronze badges asked Nov 23, 2009 at 17:14 MishigenMishigen 1,2616 gold badges26 silver badges37 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 4

Try:

return false;

Yes, you can do show(); return false; in the button's onclick handler.

onclick="show();return false;"

it's very simple: insert aber the "Alert('msg');" a "return false;".

so:

function show()
{
alert('Hallo');
return false;
 }
发布评论

评论列表(0)

  1. 暂无评论