Disable link with the prototype observe method...

Posted by enyo on Stack Overflow See other posts from Stack Overflow or by enyo
Published on 2009-09-09T13:12:35Z Indexed on 2010/05/11 13:34 UTC
Read the original article Hit count: 230

I want to create a link like this:

<a href="http://example.com">text</a>

and replace the behavior so that the link downloads the content with Ajax instead when clicking.

It is important for me not to replace the href attribute (so copying the link still works).

One solution would be to do:

$('link').onclick = function() { return false; };

but I would like to use the .observe method. But this doesn't work:

$('link').observe('click', function() { return false; });

(which is quite logical).

Any ideas on how I could achieve this?

Thanks.

© Stack Overflow or respective owner

Related posts about prototype

Related posts about JavaScript