Here is my iframe it is inside a div with a button
function myFunction() {
var url =document.getElementById("myFrame").getAttribute("src");
var newUrl = url.substring(0,url.indexOf("width")) + "width=320&height=270";
document.getElementById("myFrame").setAttribute("src",newUrl);
document.getElementById("myFrame").setAttribute("style","border:none;overflow:hidden;width:320px;height:270px;");
}
<div style="width:auto;height:auto;" id="mydiv">
<iframe id="myFrame" src="http://domain.com/page.php?width=400&height=400" height="400" width="400"></iframe>
</div>
<button onclick="myFunction()">Change Size</button>
Run codeHide resultWhat I need is my code work, it will resize the iframe, and its src link is the size. But, as you can see, my div with the identifier "mydiv" has the width and height of the style. What I need is that my code is also 100% full width in width and height, when I make the window larger than the div, the size increases, but the iframe does not change, because it has a fixed size.
I tried
("style","border:none;overflow:hidden;width:100%;height:100%;")
("width")) + "width=100%&height=100%"
but it does not work correctly. Or iframe is corrupted, but does not work correctly. I hope you understand that I really need help with this.