Maybe you can just add "return false;" to the end of the javascript code?
I'm not sure if it works but as far as I know it avoids postbacks after button clicks for example.