+ 22
[SOLVED] How does this OK appear in the alert box.can we write code to change it.Or can we replace ok with Reload or Cancel?????
JavaScript alert box section..
15 Antworten
+ 9
You can't change the alert box, but you can create your own modal pop up. Have a look at confirm() instead of alert() and see if that suits your needs better before you do that though.
+ 10
Divya Mohan thx for your ans😄🤗
+ 9
Russ could you pls send some examples of code to here? I'm also curious abt it! 😄🤗
+ 8
Divya Mohan it appears error
https://code.sololearn.com/WBeuV5Haxw0o/?ref=app
+ 7
Russ how could I change the value of 'cancel' and 'ok' in the alert Box?
And how could I modify the alert box by adding some image on it, e.g.
+ 7
Divya u are so good at JS
+ 6
WenHao1223 As basic an example as I can think of.
let conf = confirm("Ok or Cancel?");
if (conf) {
alert("Ok clicked!")
} else {
alert("Cancel clicked!")
}
Basically the return value of confirm() is a boolean - either true or false. If "OK" is clicked, confirm() returns true, and false if Cancel is clicked.
+ 6
Okk,thanks
+ 5
Thank uu divya...
+ 5
See this if you have any problem
sorry if error in previous code
WenHao1223
https://code.sololearn.com/Wt5p4O33LVUA/?ref=app
+ 4
WenHao1223 Can't be done I'm afraid. If you want to do that, you'll have to create your own (or find some other software that will fo that for you).
+ 4
Use sweetalert for custom alert box.
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
In script simply write
swal({
title: "Good job!",
text: "You clicked the button!",
icon: "success",
button: "Aww yiss!",
});
You can edit every thing in this alert box .
+ 3
Bore with College stuff
trying coding for interesting and fruitfull time
+ 2
Must use item..
👍👍
+ 2
Thanks Alphin Sajan
But js is universe and I'm just know about earth
Thaks for compliment.
It's motivational to learn more.