Search code examples
javascriptinternet-explorer-7clickprototypejsobserver-pattern

prototypejs observe IE7


I a have a link where I want to redefine the action onclick. I have to use Prototype as framework. So I use the function observe.

<a id="mylink" href="http://www.google.com/">Google</a>
<script type="text/javascript">
$('mylink').writeAttribute('onclick', 'return false');
$('mylink').observe('click', function () { /* do some stuff */ return false; });
</script>

This code is working for mostly all browser, but IE7 style making the redirect after what. Do you know how to stop this redirection?

Thanks


Solution

  • $('mylink').observe('click', function(event) {
        /* do some stuff */
        event.stop();
        return false;
    });