How can I access iframe src from HTML script

Hi, I want to change the iframe source link dynamically from ui.js

//-------call this function from entry.js

image

//and place the link in an iframe attribute---------

It shows me null in console. need help

Hi @HasnainX,

How and where are you calling your open_in_iframe() method?

To update the iframe src you don’t need style in your member selection, do this instead:

document.getElementById('minigame').src = minilink;
3 Likes

Thanks for your reply I’m calling in my entry.js script where a random button has been generated. I have tried this method but didn’t work

document.getElementId(‘minigame’).src=minilink;

it shows me null in the console again

image

That’s the browser complaining that there is no element found with minigame as ID. Are you sure that one exists?

Hey @HasnainX,

It looks like the iframe isn’t in the DOM if the browser is showing that error…How are you adding the HTML?

1 Like

Its working thanks

1 Like