How do I make an alert? [duplicate]

0

When I click on a button, will it be possible to see a dialog box with the yes or no buttons? If I load the sim to one side if I load it, it will not stay on the page. Is it possible?

    
asked by anonymous 24.06.2015 / 14:59

3 answers

0

You can do it the traditional way via javascript. However the options are set to ok or cancel, since confirm is implemented internally in each browser.

<script>
    confirma() {
        if (confirm('Deseja realmente fazer determinada ação?')) {
            // código caso tenha confirmado
        } else {
            // código caso tenha cancelado
        }
    }
</script>

<button onClick="cofirma();"> Botão de confirmação <button>

If it does not suit what you want, since it is something much more specific, I recommend looking for a solution via a plugin, such as Bootstrap modals.

    
24.06.2015 / 15:10
0

You can use the confirm function that is native to browsers. It returns true or false according to the user response.

if (confirm('Deseja ir para a página de configurações?')) {
    window.location.href = 'config.php';
}
    
24.06.2015 / 16:35
0

It's possible, yes, you can do it this way:

if (confirm('Deseja mudar de pagina?')) {
     window.location.href='http://google.com';
} else {
    // fica na pagina
}

You can use javascript, you can look at this link , and in that here is an example

    
24.06.2015 / 15:09