Call your Function in Javascript
To call your function in Javascript:
First,
create your function.
function makeBread() {
alert("Bread's Done!");
}
To call your function inside of <script> tags, simply call it like so:
makeBread();
To call your function from a link, in your <a href tag, use
Javascript's onClick:
<a href="http://google.com" onClick="makeBread();return false">Call function from a link.</a>
-when this link is clicked, anything inside the function
makeBread will be executed.
-the
return false statement stops the browser from loading the link, in this case, google.
-
return true would send the user's browser to google.
Call function Make Bread from this link.
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
function makeBread() {
alert("Bread's Done!");
}
makeBread();
-->
</script>
<a href="http://google.com" onClick="makeBread();return false">Call function from a link.</a>
Resources:
Create a Function in Javascript