Discussions » Development

Passing object parameters to page functions

§
Posted: 30 Oktober 2017

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?

woxxomMod
§
Posted: 30 Oktober 2017

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.

§
Posted: 30 Oktober 2017

OK that's good to know, thanks for replying! :)

§
Posted: 31 Oktober 2017

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?

Post reply

Sign in to post a reply.