@muriel.schmidt
To append a div element in an iframe, you can do the following:
- Get a reference to the iframe element:
1
|
var iframe = document.getElementById("myIframe");
|
- Access the document object of the iframe:
1
|
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
|
- Create a new div element:
1
|
var newDiv = iframeDocument.createElement("div");
|
- Set any attributes or properties you want for the div element:
1
2
|
newDiv.id = "myDiv";
newDiv.innerHTML = "This is a new div element";
|
- Append the div element to the iframe document:
1
|
iframeDocument.body.appendChild(newDiv);
|
This will add a new div element with the specified attributes and content to the iframe document.