seems unbelieveable.
 JS 闭包 计数器
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
# <html>  
#  <head>  
#     <title>JS Counter</title>  
#     <script type="text/javascript">  
#     var Counter=(function(){  
#           
#         //赋初值  
#         var count=0;  
#   
#         //外部调用时形成闭包  
#         return function(){            
#             return ++count;  
#         }  
#     })()  
#   
#     window.onload=function(){  
#         document.getElementById('btn').onclick=function(){  
#                alert(Counter());  
#         }  
#     }  
#       
#          </script>  
#   
#  </head>  
#   
#  <body>  
#     <input type='button' id='btn' value='Counter' />  
#  </body>  
# </html>