Javascript examples for Object:prototype
Add method to Element
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w .ja va 2 s .co m*/ var el = document.getElementsByTagName('audio')[0]; Object.defineProperty(el, 'src', { set: function (newSrc) { console.log('they set src to ' + newSrc); } }); el.src = 'http://example.com/sounds.mp3'; } </script> </head> <body> <audio></audio> </body> </html>