[thelist] Simple JavaScript question

James Spahr james at designframe.com
Mon Aug 7 07:21:56 CDT 2000


on 8/7/00 5:40 AM, Peter Small at peter at genps.demon.co.uk wrote:

> Wouldn't the return have to be included in an if... then... conditional -
> to direct the transfer to another URL only if true was returned by the
> confirm() function?


><script LANGUAGE="JavaScript">
>  <!--
>    function proceed2() {
>      return confirm("Are you sure?") ;
>    }
>  -->
></script>
>
><a href="http://www.citycent.com" onClick="return proceed2();">Click
>here</a>
>

Basically if onClick returns true, the browser will follow the standard
click behavior of the element (in this case you get to go to another page).
If the onClick event returns false - the browser does not execute the
standard click behavior.

So, as you know confirm return true or false, so all you really need to is
pass that value back to the <a> tag.

Make sense?

James.






More information about the thelist mailing list