<!DOCTYPE HTML> <html> <head> </head> <body> <div id="t"> </div> <script> var elem = document.getElementById("t"); elem.onclick = function () { alert(""); } elem.click(); </script> </body> </html>