<html lang="en">
<head>
<title> Add button inside iframe using javascript</title>
</head>
<body>
<p>Click on the <b>Add Button</b> to append a new button element inside the iframe.</p>
<button onclick="addBtn()">Add button</button>
<iframe id="iframe-id" src="https://search.3schools.in/p/example.html" style="height:370px;width:100%">
</iframe>
<script>
function addBtn() {
const myIframe = document.getElementById("iframe-id");
const divElement = myIframe.contentWindow.document.querySelector('#div');
const newElement = document.createElement('button');
newElement.innerHTML="New Button Element";
divElement.appendChild(newElement);
}
</script>
</body>
</html>