Link focus() and blur()
<html> <head> <style type="text/css"> a:active {color:blue} </style> <script type="text/javascript"> function getfocus(){ document.getElementById('java2s').focus() } function losefocus(){ document.getElementById('java2s').blur() } </script> </head> <body> <a id="java2s" href="http://www.java2s.com">Visit Java2s.com</a> <form> <input type="button" onclick="getfocus()" value="Get Focus"> <input type="button" onclick="losefocus()" value="Lose Focus"> </form> </body> </html>