0

I'm trying to create a new object (event) in my javascript code from an another event (window.event). I would like to create this one new event byVal e not byRef because i need this event also window.event were dead. This code must be ie7 compatible.

I tryied this but doesn't work :-(

function copyMyEvent(p) {
  if (!p) throw Error('no type');
  function f() {};
  f.prototype = p;
  return new f();
};

var event = copyMyEvent( window.event );

Thx

Simo3112
  • 1
  • 1

1 Answers1

0

I am not 100% sure, but you might want to stringify and then re-evaluate the code to make this happen. You should try some of the polyfills for deep object copy.

Check this question: What is the most efficient way to deep clone an object in JavaScript?

Martin Chaov
  • 824
  • 7
  • 17