iframe.setAttribute -> illegal

Im having an issue where I am linking to another html page via the info box. The error happens because the “allow scripts” option needs to be true on the viewer.infobox.container but it appears this is a Read-only attribute. Heres the code snippet that returns the error:

var infobox = viewer.infoBox.container;
var iframe = infobox.getElementsByClassName('cesium-infoBox-iframe');
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups allow-forms');

The last line of code wont execute says iframe.setAttribute is not a function.
This topic is related to my initial post here: https://community.cesium.com/t/how-to-set-allow-scripts-permissions/23098