Script Examples
Transmit data from Webpage to UI Builder WebPage Component
In this example, we can transmit data from the UI Builder WebPage component to the Web Page iframe element as well as transmit data from the Web Page iframe element to the UI Builder WebPage component.
Setting it up
- Save the
iframe.htmllisting below somewhere your browser can reach it, and note its URL. - Add a Web Page component to your user interface, name it
webPageComponentand set its URL property to that address. The same works for a Web App component: both supportonMessageandpostMessage. - Add a text input named
message(what you send), a text input namedreceive(what you get back) and a button namedsendBtn. - Paste the script below.
UI Builder Script(WebPage.ezui)
1 2 3 4 5 6 7 | |
Tip
The event also carries e.origin, the origin of the window that sent the message. Check it before trusting e.data if the page can be loaded from more than one source.
Warning
postMessage is forwarded straight to the embedded page. If the page has not finished loading there is no window to deliver to and the message is dropped without an error, so send only after the page is up - for example from a button, as above, rather than at script start.
iframe.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |