Passing object parameters to page functions

If I want to call a javascript function in the page which takes an object as a parameter, is this the correct way to do this from a script, or is there a better way?

var obj = {blah:blah};

var result = unsafeWindow.PageFunction(cloneInto(obj,unsafeWindow));

I'm worried about it causing a memory leak, should I be?


  • Supposedly, the clone should get garbage-collected automatically when it's no longer used so all depends on the PageFunction - whether it properly releases the object or not.

  • OK that's good to know, thanks for replying! :)
  • Oh damn, I can't do it like this if the object contains a function, get the error

    "Permission denied to pass a Function via structured clone"

    So what's the best approach in this instance?
Logg inn eller Registrer deg for å kommentere.