Team:UCLA/anuved verma ucla2014 workspace
From 2014.igem.org
(Difference between revisions)
Anuvedverma (Talk | contribs) |
Anuvedverma (Talk | contribs) |
||
Line 12: | Line 12: | ||
<script type="text/javascript" charset="utf-8"> | <script type="text/javascript" charset="utf-8"> | ||
- | function addEvent(obj, evt, fn, capture){ | + | function addEvent(obj,evt,fn,capture){ |
- | evt = evt.replace('on', ' '); | + | evt=evt.replace('on',''); |
- | if(obj.attachEvent) | + | if(obj.attachEvent){ |
- | obj.attachEvent('on' + | + | obj.attachEvent('on'+ evt,fn); |
+ | } | ||
else{ | else{ | ||
- | if(!capture) capture = false; | + | if(!capture){ |
- | + | capture=false; | |
+ | obj.addEventListener(evt,fn,capture); | ||
+ | } | ||
+ | } | ||
} | } | ||
- | |||
var box = document.getElementById('box'); | var box = document.getElementById('box'); | ||
addEvent(box, 'click', function(){ | addEvent(box, 'click', function(){ | ||
alert('clicked'); | alert('clicked'); | ||
- | + | }) | |
</script> | </script> | ||
</body> | </body> | ||
</html> | </html> |
Revision as of 20:41, 11 July 2014