Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   Linking to javascript function (http://www.go4expert.com/forums/linking-javascript-function-t6434/)

Talks_44 19Sep2007 21:55

Linking to javascript function
 
There's a few different ways people create links to javascript function, after some looking around here's what seems to be the better ways:

CODE
<a href="java script:{}" onclick="foo()">Call it</a>
<a href="java script:;" onclick="foo()">Call it</a>
<a href="java script:void(0);" onclick="foo()">Call it</a>

<a href="#" onclick="foo(); return false">Call it</a>


And many people will say to back it up with a server-side page or needs-JS page like:

CODE
<a href="jsrequired.html" onclick="foo(); return false">Call it</a>

pradeep 20Sep2007 10:40

Re: Linking to javascript function
 
onClick is the most popular way to link to JavaScript calls, people sometimes link this way too..

Code: HTML

<a href='javascript:myFunc();'>Call myFunc</a>


Talks_44 21Sep2007 20:40

Re: Linking to javascript function
 
Quote:

Originally Posted by pradeep
onClick is the most popular way to link to JavaScript calls, people sometimes link this way too..

Code: HTML

<a href='javascript:myFunc();'>Call myFunc</a>



Gratz for completing me!!!


All times are GMT +5.5. The time now is 11:31.