Imagine you're inserting this script directly into the html file that includes the "parent" window code (which also contains the iframe). To ensure the iframe is properly defined when this code runs, position the script block after the iframe element, or utilize a window.onload or document.ready handler.
<iframe class='content-frame'></iframe>
...
<script>
document.getElementsByClassName("content-frame")[0].addEventListener("load", function () {
// once the iframe's document has loaded, hide the ribbon bar
var ribbonBar = this.contentDocument.getElementById("suiteBarDelta");
if (ribbonBar) {
ribbonBar.style.visibility = 'hidden';
} else {
console.log("Uh oh, ribbonBar still doesn't exist");
}
});
</script>
I can't be certain if Sharepoint utilizes complex processes to construct content within the iframe (such as asynchronous requests to fetch the ribbon bar) - if it does, this code will break and you'll see the "Uh oh" message in the console.