JavaScript: Confirmation Box

From The Travis van der Font Wiki
Jump to: navigation, search
HTML:
<a href="javascript:void(0);" id="example_id">Click Me</a>
Source Code (JavaScript):
document.getElementById('example_id').addEventListener('click', function (event)
{
    if (confirm('Are you sure that you want to do this?') === true)
    {
        // ....
    }

    event.preventDefault();
});