code_junkie

What is the difference between the different methods of putting JavaScript code in an <a>?

Nov 12th, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. function DoSomething() { ... return false; }
  2.  
  3. <a href="javascript_required.html" onclick="doSomething(); return false;">go</a>
  4.  
  5. <a href="#" onClick="DoSomething(); return false;">link</a>
  6.  
  7. <a href="#" id = "Link">link</a>
  8. (document.getElementById("Link")).onclick = function() { DoSomething(); return false; };
  9.  
  10. 5: <a href="#" id="myLink">Link</a>
  11.  
  12. document.getElementById('myLink').onclick = function() {
  13. // Do stuff.
  14. };
Add Comment
Please, Sign In to add comment