How to get a JS variable value through a bubble embed?

This store doesn’t have a rating system by default, so a started to build one via bubble, the store only accepts javascripts and HTML codes to be inserted.

So on the store panel i maked this code to show the embeded page that will show the comments/ratings and also gets the product id that’s inside a hidden input.

//gets the product id that's inside a hidden input

const produto_id = document.querySelector('input[name="produto_id"]').value;

//inserts the iframe inside the div .secao-secundaria
const corpo = document.querySelector(".secao-secundaria");
const embed = document.createElement("iframe");

// Define  the properties of the iframe
embed.setAttribute('src', '');
embed.setAttribute('width', '100%');
embed.setAttribute('height', 'auto'); = "none"; // Remove borders = "hidden"; // Remove  scroll


With that i was able to display the embed bubble correctly, and show the id in the console.log.

Captura de tela 2023-06-13 162724

However i’m having issues trying to get this id on bubble via JS, i tried using this line of code on toobox that should get the value, but it doesn’t.

const produto_id = document.querySelector('input[name="produto_id"]').value;


Captura de tela 2023-06-13 164621

Any ideas that can solve this? what i’m doing wrong :man_shrugging:, thanks in advance.

Are you trying to manipulate the DOM of the website inside the iFrame? Or are you trying to simply access information from the iFrame. Also, I would suggest moving this post to the plugins builder sub forum because the people there are more familiar with code.

No, i’m just trying to get the product id to make a search on bubble db and show only the commets related to that product. Maybe i dind’t make myselft clear, but there’s a store and on the footer i embed bubble page that will have a RG where i make a search and that search needs to filter the comments related to the product page, all i wanna to do is get the product id of the page on the embed to make that.

This topic was automatically closed after 70 days. New replies are no longer allowed.