PDA

View Full Version : onclick function medaling Q?


scroots
08-28-2002, 07:01 PM
if i had a script to detect an onclick on a page and the user clicked a hyperlink what would happen
would any of the following happen?
a) an error get produced
b) the function is performed and the link doesn`t work
c) the link works but the function is not performed
d) the link and function BOTH work
e)other, please explain

scroots

beetle
08-28-2002, 07:14 PM
e) other:

The page will perform the link and TRY to do the function, but the browser may not have time to complete it before the page hops. To get (d) as a result, you need to listen for the function to complete, and allow the default action of the click to proceed.<script>
function clicker() {
alert('Clicked!');
return true;
}
</script>

<a href="page.htm" onClick="return clicker();">link</a>

scroots
08-28-2002, 07:59 PM
thanks beetle

scroots