I have a JavaScript alert button that appears on the website when a user is going to proceed to a signup page.
It looks something like this
Would you like to proceed to the signup page?
< OK > < Cancel >
Would it be possible to add a third button to the alert so that it looks like
Would you like to proceed to the signup page?
< More Info > < OK > < Cancel >
An alert box is used to inform/alert the user about an event. This type of popup box has only one button, named 'OK', and has no return value.
One useful function that's native to JavaScript is the alert() function. This function will display text in a dialog box that pops up on the screen. Before this function can work, we must first call the showAlert() function. JavaScript functions are called in response to events.
To create a custom alert box in JavaScript, you can use the “SweetAlert library, which includes a “CDN” file to enable the “Swal. fire()” method, and “JQuery” library, which will load the JQuery library in the project, fetch various attributes of the alert box and apply different functionalities on the alert box.
The alert() method displays an alert box with a message and an OK button. The alert() method is used when you want information to come through to the user.
Nowdays, you can use an HTML dialog
element.
<dialog open>
<p>Greetings, one and all!</p>
<button>Ok</button><button>Maybe</button><button>Cancel</button>
</dialog>
And do what you want with it.
document.querySelectorAll('button').forEach($button =>
$button.onclick = () => document.querySelector('dialog').removeAttribute('open'))
https://jsfiddle.net/6nus2zt4/1/
Hope this help to future generations :)
however you can use confirm function.. but NOT three buttons.
var r=confirm("Press a button!");
if (r==true)
{
x="You pressed OK!";
}
else
{
x="You pressed Cancel!";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With