I need help with this logout link i made

When you click it, it should show a confirm box, but it doesn't.

Heres the Javacript

<script language='javascript'>
function confirm(){
var f = confirm("Are You Sure You Want To Logout?");
if(f){
return true;
}
else{
return false;
}
}
</script>

And heres the link

<a href='logout.php' onClick='return confirm()'>logout</a>

Plz help??

Hi DealthRune,

you could try this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Free Live Help!</title>
<script type="text/javascript">
<!--
var _confirm = function() {

   if ( confirm("Are You Sure You Want To Logout?"))
     location.replace("logout.php");
  
};
// JavaScript-1.5 -->
</script>
</head>
<body id="body">
<div id="div">
<a href="#" onclick="_confirm();">Logout</a>
</div>
</body>
</html>

Oouoo thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.