1
I would like to run the javascript below using href.
But by clicking on the supposed link Log Out, nothing happens. If I hold the cursor over the link it shows me the destination as javascript:logout()
function logout() {
var choose = confirm("Deseja realmente sair?");
if (choose == true) {
location="Main.html";
} else {
}
<nav id="menuOp">
<a href="javascript:logout()">Log Out</a></br>
<b>Olá, #</b>
</nav>
Do you really have to use href? For what reason?
– Joao Paulo
When a javascript code does not work, open the browser console and see if it prints out any error messages. If what happened is what @Joaopaulo said, probably allgum error was spat on the console and you wouldn’t even need to have created that question...
– Caique C.
You opened it up
function logout() {
but did not close with}
, and a typo.– Guilherme Nascimento