D
Dave
Hi,
I tried something with 'return value' of a function and i got two different
behaviours.
My question is: why does method 1 not work?
Thanks
Dave
method 1: here, whatever i choose (ok or cancel), i go to 'webpage.htm'
<body>
<a id="my" onClick="retvalue()" href="webpage.htm" >click here</a>
<script type="text/javascript">
function retvalue()
{
if (confirm("go to link?") == false)
return false
}
</script>
</body>
method 2: here, when clicking on 'cancel', i don't go to 'webpage.htm'
<body>
<a id="my" href="webpage.htm" >click here</a>
<script type="text/javascript">
function retvalue()
{
if (confirm("go to link?") == false)
return false
}
document.getElementById("my").onclick=retvalue
</script>
</body>
I tried something with 'return value' of a function and i got two different
behaviours.
My question is: why does method 1 not work?
Thanks
Dave
method 1: here, whatever i choose (ok or cancel), i go to 'webpage.htm'
<body>
<a id="my" onClick="retvalue()" href="webpage.htm" >click here</a>
<script type="text/javascript">
function retvalue()
{
if (confirm("go to link?") == false)
return false
}
</script>
</body>
method 2: here, when clicking on 'cancel', i don't go to 'webpage.htm'
<body>
<a id="my" href="webpage.htm" >click here</a>
<script type="text/javascript">
function retvalue()
{
if (confirm("go to link?") == false)
return false
}
document.getElementById("my").onclick=retvalue
</script>
</body>