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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

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

Post 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
User avatar
tasteslikepurple
Forum Commoner
Posts: 46
Joined: Thu Jan 26, 2006 3:38 am
Location: Bath, UK

Post 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>
Post Reply