admin管理员组文章数量:1313809
I want to execute some code when an alert is accept by the user, I know about this:
if(confirm("Go to the next step"))
{
document.write("accepted");
}
else{
document.write("rejected");
}
the point is I want the box to have only one button like the normal alert, and by clicking it I can execute something.
I want to execute some code when an alert is accept by the user, I know about this:
if(confirm("Go to the next step"))
{
document.write("accepted");
}
else{
document.write("rejected");
}
the point is I want the box to have only one button like the normal alert, and by clicking it I can execute something.
Share Improve this question asked May 7, 2012 at 5:52 Ahmed WaheedAhmed Waheed 1,2916 gold badges21 silver badges39 bronze badges 3-
simple if you want only one button and forcefully ask the user to accept the
alert
then usealert
box rather thanconfirm
. – Murtaza Commented May 7, 2012 at 5:55 - What do mean by displaying only one button and right the code to check user has accepted or not. He will have to forcefully accept it, thats the only option for user. – Murtaza Commented May 7, 2012 at 5:56
-
actually you are already executing something ...
document.write(...)
is your action – user57508 Commented May 7, 2012 at 5:57
3 Answers
Reset to default 8You can use the alert
mand in javascript: http://www.w3schools./js/js_popup.asp
I believe any line of javascript code that is placed after the alert
line is executed after the alert window closes.
Whatever statement you put after alert
will be executed when user clicks on okay.
Fiddle
And when you say alert user don't have any other choice other than clicking on okay.
alert()
- One button (OK) Try a demo: http://jsfiddle/DerekL/3R3yV/confirm()
- Two buttons (OK, cancel)prompt()
- Two buttons + one input field (OK, cancel)
For other buttons, you might want to try out jQuery UI.
jQuery User Interface does let developers to create custom dialogs.
本文标签: javascriptDo something upon accepting an alertStack Overflow
版权声明:本文标题:javascript - Do something upon accepting an alert - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741914750a2404659.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论