The using js code in html isn't very good but you can use such approach for small handlers like this. But are you sure that your handler of this event will work in IE8 and IE9? (Are you sure that it's universal way to process such situation?)