Javascript functions can return values. One example is the built-in function confirm(), which pops up a yes/no dialog box and returns true or false depending upon the user's response. But you can also write your own functions that return values. This page includes a few simple examples.
You can also use return values to control the activity of a link, as this example shows: Back to CSC 105 home