Javascript examples for DOM:Event
Add on click event handler for created div element
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function () {/* w ww .j a v a2s . c o m*/ var DivTag = document.createElement("div"); DivTag.setAttribute('id', 'MyDivTagID'); DivTag.innerHTML="Click"; DivTag.onclick = function(e) { window.location = "http://www.your server.com/?Url=" + escape(window.location.href); } document.body.appendChild(DivTag); } </script> </head> <body> </body> </html>