Iframe in Scene


#1

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


#2

Good luck. :slight_smile:


#3

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.


#4

first i try this

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

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

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

iframe.align = ‘center’

iframe.src = ‘http://www.kidsinmotion.mx/jardin-de-ninos.html’;

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


#5

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


#6

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();

#7

Any demo example to me see how works?