I tried using document.getElementById("frame-id"), but it seems buggy. Mostly it returns undefined or null but sometimes it returns the iframe only for the first time it is called then again it starts returning undefined. Also I am unable to change or get style properties with document.getElementById("frame-id").style.width. E.g. here is the fiddle https://jsfiddle.net/Lfq2u2o1/1/ You can check with the console.
Why are iframe elements not accesible with document.getElementByid or document.getElementsByClassName in javascript?