You can do with a same link tag (<a></a>) and the function confirm of Javascript. Example:
<a href="https://www.google.com/" target="_blank" onclick="return confirm('Deseja realmente sair?');">Sair do site</a>
Detailing:
The event is added onclick on the tag a which returns the function result confirm.
The function confirm is native to Javascript, and opens a window displaying the text passed as parameter, an 'OK' button and an 'Cancel' button. If the user clicks 'OK', the function returns true. If the user clicks 'Cancel', the function returns false.
On returning false for the event onclick, it interrupts the execution of the element’s standard action, which in the case of the tag a is the call to the link specified in the attribute href.
Note: Semantically, the most suitable for this action would be the use of the tag <a></a>, because by definition, indicates the link of the current page with another page. You can read more about the definition and use of the tag a in: https://www.w3schools.com/tags/tag_a.asp
Is there any code you’ve tried? Have you looked at
confirmofJavascript? https://www.w3schools.com/jsref/met_win_confirm.asp– Ricardo Pontual
I wanted something simpler, without having to make too many conditions.
– Gonçalo