Iframe in Scene

im tryin to get an iframe in a scene with JS.

Good luck. :slight_smile:

One possibility is to do this outside of GDevelop. You can export your GDevelop to local folder and then modify the index.html to inject your iFrame there before hosting.

first i try this

var iframe = document.createElement(‘iframe’);

iframe.setAttribute(‘width’, ‘560’);

iframe.setAttribute(‘height’, ‘315’);

iframe.align = ‘center’

iframe.src = ‘Jardin de Ninos’;

document.body.appendChild(iframe);

and it work but the iframe was behind the background layer them i add this

iframe.style.position = “absolute”

iframe.style.zIndex = 1000;

and now is visible and working…still working to improve it

1 Like

How can I delete the iframe again? e.g. when changing the scene.

Before add a className to your iframe element when this one is created.

iframe.id = "myIframeToDelete";

Then later when you want delete it.

//get the iframe by id
const myIframe = document.getElementById('myIframeToDelete');
// delete it
myIframe.remove();
1 Like

Any demo example to me see how works?