How to pass a parameter from custom code back to page?

Hello,
Is this possible? I have embedded a custom code snippet using settings → add custom code. I need to access certain variables in the custom code from the page.

Any pointers? Thanks.

Pass that value using url query (window.location in the custom code) and use wixLocation.onChange() to receive in the wix page

From wix to custom code use wixWindow.postMessage to send and EventListener(“message” …) on custom code.

I guess you can to create a Custom Element to get the custom code var and sent to page using dispatchEvent( new CustomEvent( ‘my-event’ , { detail: data }));
In the wix page user element.on() event to listen

That works ! Thank you :slight_smile: