Getting rid of inline onclick calls and registering the handler in the primary script ensure securty (XSS).