Page 1 of 1

Execute function only when called? Working JS provided...

Posted: Fri Jan 27, 2006 9:38 pm
by JAB Creations
I have a script that works fine and dandy save but that it automatically executes for the whole page.

The working script...

Code: Select all

function preview(event) {alert("disabled"); return false;}

Code: Select all

<a href="#" onclick="preview();">link</a>
I want to call this function but only for the anchors I specify. How do I code the function to execute only when called?

John

Posted: Sat Jan 28, 2006 4:09 am
by tasteslikepurple
it works fine for me, I tested it on 3 mac browsers (firefox, internet explorer and safari). here is my code:

Code: Select all

<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">
function preview(event) {alert("disabled"); return false;}
</script>
</head>
<body>
<a href="#" onclick="javascript:preview()">link</a>
</body></html>