View Single Post
Old 04-21-2009, 10:04 PM   #1 (permalink)
allworknoplay
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default JS in a href.......

can someone explain to me fundamentally what this does?


<a href="javascript:myFunction();">

I assume that the first part "javascript" is calling
my javascript up in the header?

<script type="text/javascript"></script>

And myFunction is calling a function that is within that script?



So hypothetically, if I did this, then it's the same philosophy?

<script type="text/whatever"></script>


<a href="whatever:myFunction();">



Also, why is it that when calling a function outside of the
javascript tags, you use the parenthesis "()"..

But within it, you don't? Like this...

Code:
<script type="text/javascript">

var clickCount = 0;
function documentClick(){
    document.getElementById('clicked').value = ++clickCount;
}
document.onclick = documentClick;

</script>
How come:

document.onclick = documentClick;

Doesn't use parenthesis? Shouldn't it be?

document.onclick = documentClick();
allworknoplay is offline  
Reply With Quote