Peringatan JS
alert("Hello! I am an alert box!!");
Testy Turtle
alert("Hello! I am an alert box!!");
// window.alert(message);
/*
`window.alert` opens a dialog with an "Ok" button. Upon
receiving input, the dialog is closed.
*/
window.alert("Warning! Something has happened...");
/*
Note that this will pause code execution until
the dialog receives input. You can't fully get
around this, however using asynchronous
functions or promises, you can get other
statements to be called just after the dialog
is closed and before the dialog returns its
response.
*/
window.alert = (function() {
const synchronous_confirm = window.alert;
return async function(message) {
return synchronous_confirm(message);
};
})();
// OR
window.alert = (function() {
const synchronous_confirm = window.alert;
return function(message) {
return new Promise((res, rej) => {
try {
res(synchronous_confirm(message));
} catch (error) {
rej(error);
}
});
};
})();
//toastr Sweet Alert
//css
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css" integrity="sha512-3pIirOrwegjM6erE5gPSwkUzO+3cTjpnV9lexlNZqvupR64iZBnOOTiiLPb9M36zpMScbmUNIcHUqKD47M719g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
//must have
var Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000
});
//how to use toastr:
Toast.fire({
icon: 'success',
title: 'Successfully Created.'
})
//or
toastr.success('Successfully Created.')
//js
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js" integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<button onclick="alert('Hello! You clicked the button!');">
Click to Trigger Alert!
</button>
alert("Example alert")