admin管理员组文章数量:1416083
Is there anyway I can change the options for the JavaScript confirm();
function? I want the options to be red and green so I can do this.
var color = confirm("Do you like red or green better");
if(color == true) {
document.body.style.background = red;
} else {
document.body.style.background = green;
}
Is there anyway I can change the options for the JavaScript confirm();
function? I want the options to be red and green so I can do this.
var color = confirm("Do you like red or green better");
if(color == true) {
document.body.style.background = red;
} else {
document.body.style.background = green;
}
Share
Improve this question
asked Jan 20, 2016 at 1:02
Adam OatesAdam Oates
1151 gold badge2 silver badges7 bronze badges
1
- 1 Possible duplicate of: stackoverflow./questions/22885897/… – Halfpint Commented Jan 20, 2016 at 1:06
2 Answers
Reset to default 2No, you can't.
That happens for security reasons, styling the Confirm
and Cancel
buttons would open doors for attackers to abuse this feature in sort of obvious ways (Making the Cancel
button hard to see, changing Confirm
to Cancel
, etc)
You can create a customised modal pop-up, though. Many CSS frameworks and Javascript plugins provide a basic and easy to use template for that, like Bootstrap, Foundation, and assorted jQuery and vanilla Javascript plugins
You can't customize confirm
function.
If you really need to dialog customization, I remend this. jQuery UI - Modal confirmation
本文标签: htmlCan I change options in confirm() in JavaScriptStack Overflow
版权声明:本文标题:html - Can I change options in confirm(); in JavaScript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745245142a2649521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论