forse questo ti può aiutare
http://www.html.it/javascript/corso/js_28.htm