Mira a ver si te vale esto
Código HTML:
<html>
<head>
<title>Interruptor</title>
<script>
var n=0
function interruptor(){
n++;
if(n%2==0){return "1";} else return "0";
}
</script>
</head>
<body>
<p><a href=# onclick="alert(interruptor())">Un enlace</a></p>
</body>
</html>