how i can customize the code of iframe and connect it to my database?
thanks!
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
Thanks!
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:
https://www.wix.com/code/reference/wix-dataset.html#getCurrentItem
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
Thanks for your reply, but i mean how can i link my iframe html code on dynamic page to my databae?
Use Wix already provided.
https://support.wix.com/en/article/adding-a-paypal-button-280640
Or add it via html onto your page.
https://www.paypal.com/us/smarthelp/article/how-do-i-create-a-paypal-button-using-the-wix-html-widget-ts2001
https://support.wix.com/en/article/adding-html-code
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.
https://www.wix.com/corvid/reference/$w.HtmlComponent.html