Discussions » Development

Passing object parameters to page functions

§
Posted: 2017-10-30

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: 2017-10-30

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: 2017-10-30

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

§
Posted: 2017-10-31

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.