Question : Is it possible to change the onclick stuff by Javascript?

Hello guys

I have for one image the event onclick="openNewWindowA()"

but I'd like to exchange its fire, to call another function, is it possible to exchange it?

thanks

Answer : Is it possible to change the onclick stuff by Javascript?

Or, more  closely related to programming way:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
<img id="testimg" onClick="openNewWindowA();">

<script>
var oldevent = null;

function newOnClickEvent(e) {
  // begin of newOnClickEvent implementation
  // ...
  // end of newOnClickEvent implementation

  if (typeof oldevent == 'function') oldevent(e);
  return 0;
}

function changeOnClickEvent(imgObj) {
  var iobj = (typeof imgObj == "string") ? document.getElementById(imgObj) : imgObj;
  oldevent = iobj.onClick;
  iobj.onClick = newOnClickEvent;
}

// call to
changeOnClickEvent("testimg");
</script>
Random Solutions  
 
programming4us programming4us