how i can customize the code of iframe and connect it to my database?
Use Wix already provided.
Or add it via html onto your page.
If you are wanting to connect your html code to your page or page to html code, then you can by using the on message and post message through code.
Thanks for your reply, but i mean how can i link my iframe html code on dynamic page to my databae?
You can simply use the postMessage method to post information to an HTML iFrame. You can also check out the Messaging section of this article. This code should be added to the dynamic page code section.
Since the HTML IFrame is real IFrame, the normal way to communicate with it is by sending messages.
Basically what you need to do is:
On the page side:
- get the relevant data from the collection via dataset
- send message to the iframe with the content you want to load
On the iframe side:
- add listener for messages
- on message - to take the sent data and to load it into the body (or wherever you need it in the iframe)
Here is more details on how to work with HTML components and some examples: https://www.wix.com/code/reference/$w.HtmlComponent.html#postMessage
[see the example for the postMessage() - it sends "Message from page code!" text to the IFrame and it is then displayed in the IFrame's demo element. You might want to replace the whole body in your case, but the idea is the same)
In order to get the current item in the dynamic page, you need to use this API:
You might get some additional info from this article: "Working with the HTML Element in Wix Code" - https://support.wix.com/en/article/working-with-the-html-element-in-wix-code