Call your Function in Javascript
To call your function in Javascript:
First,
create your function.
function makeBread() {
alert("Bread's Done!");
}
To call it inside of <script> tags, simply call it like so:
makeBread();
To call it from a link, in your <a href tag:
<a href="http://google.com" onClick="javascript: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.
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
function makeBread() {
alert("Bread's Done!");
}
makeBread();
-->
</script>
<a href="http://google.com" onClick="javascript:makeBread();return false">Call function from a link.</a>
Resources:
Create a Function in Javascript
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | CSS David McFarland |
| | | |
| | | |