PDA

View Full Version : newbie: how to invoke javascript from a link


xianwinwin
10-23-2007, 04:42 PM
Hi experts,

Quick question: I'm tying to create a link that will ask the user *before* moving to the link if the user is sure he wants to do that.

In other words, I have the lines below but not sure how to integrate both.

<a href='http://www.google.com'><html:img src='./images/goog32.png' border='0' /></a>


<script LANGUAGE="JavaScript">

function confirmSubmit()
{
var agree=confirm("Are you sure you wish to go to google?");
if (agree)
location = "http://www.google.com";
else
return false ;
}

</script>

diades
10-23-2007, 04:47 PM
Hi

Just this:

<a href='http://www.google.com' onclick="return confirm('Are you sure you wish to go to google?');"><img src='./images/goog32.png' border='0' /></a>