+ 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..

27th Jul 2020, 9:33 AM
Alphin K Sajan
Alphin K Sajan - avatar
15 Respostas
+ 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.
27th Jul 2020, 9:53 AM
Russ
Russ - avatar
+ 10
Divya Mohan thx for your ansđŸ˜„đŸ€—
28th Jul 2020, 9:21 PM
WenHao1223
WenHao1223 - avatar
+ 9
Russ could you pls send some examples of code to here? I'm also curious abt it! đŸ˜„đŸ€—
27th Jul 2020, 9:56 AM
WenHao1223
WenHao1223 - avatar
28th Jul 2020, 9:19 AM
WenHao1223
WenHao1223 - avatar
+ 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.
27th Jul 2020, 10:06 AM
WenHao1223
WenHao1223 - avatar
+ 7
Divya u are so good at JS
29th Jul 2020, 4:52 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 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.
27th Jul 2020, 10:02 AM
Russ
Russ - avatar
+ 6
Okk,thanks
28th Jul 2020, 3:47 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 5
Thank uu divya...
28th Jul 2020, 3:42 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 5
See this if you have any problem sorry if error in previous code WenHao1223 https://code.sololearn.com/Wt5p4O33LVUA/?ref=app
28th Jul 2020, 4:24 PM
Divya Mohan
Divya Mohan - avatar
+ 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).
27th Jul 2020, 10:08 AM
Russ
Russ - avatar
+ 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 .
28th Jul 2020, 9:06 AM
Divya Mohan
Divya Mohan - avatar
+ 3
Bore with College stuff trying coding for interesting and fruitfull time
29th Jul 2020, 9:24 AM
Divya Mohan
Divya Mohan - avatar
+ 2
Must use item.. 👍👍
28th Jul 2020, 3:45 PM
Divya Mohan
Divya Mohan - avatar
+ 2
Thanks Alphin Sajan But js is universe and I'm just know about earth Thaks for compliment. It's motivational to learn more.
29th Jul 2020, 5:55 AM
Divya Mohan
Divya Mohan - avatar