jQuery Javascript:确认确定取消按钮上的自定义文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18420935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript : custom text on Confirm Ok Cancel button
提问by Animesh
I have a validation where i want to show 'Continue' and 'Return' instead of OK and Cancel but I am not able to find accurate solution, can anyone help me on this.
我有一个验证,我想显示“继续”和“返回”而不是“确定”和“取消”,但我无法找到准确的解决方案,任何人都可以帮我解决这个问题。
<input type="button" name="submit" value="Submit" style="font:10px;">
<xsl:attribute name="onclick">
javascript:
var amount = document.getElementById('txtboxAdjustment14').value.trim();
if(amount == 0)
{
var cont =confirm("Have you considered amount?")
if (cont == true)
{
somemethod();
}
else if(cont == false)
{
return false;
}
}
else
{
somemethod();
}
</xsl:attribute>
</input>
回答by Tushar Gupta - curioustushar
回答by Kevin Bowersox
You cannot change the buttons on the javascript confirm dialog. You would need to use a custom dialog implementation such as the one contained in SimpleModal.
您无法更改 javascript 确认对话框上的按钮。您需要使用自定义对话框实现,例如SimpleModal 中包含的实现。
回答by MD Sayem Ahmed
There's no decent cross-browser solution for doing that. I'd suggest you to use some library like jQuery UIto build a custom OK-Cancel dialog.
没有像样的跨浏览器解决方案可以做到这一点。我建议您使用诸如jQuery UI 之类的库来构建自定义的 OK-Cancel 对话框。
Check out this modal confirmation dialog.
看看这个模态确认对话框。