I want to embed a Google spreadsheet without the header and footer. This post shows the trick, but doesn't say how to apply it. I tried this, but it doesn't work:
<iframe id="embeddedthing" width='500' height='300' frameborder='0' src='https://docs.google.com/spreadsheet/pub?key=<DocId>&single=true&gid=12&output=html&widget=false&gridlines=false'></iframe>
<script type="text/javascript">
var f = function(id) {document.getElementById(id).style.display = "none";};
f("header");
f("footer");
</script>
Then I thought I should apply it to the document loaded in the iframe, so I tried to access it using document.getElementById('FrameId').contentWindow.document
, but the browser says "Unsafe JavaScript attempt to access frame" and doesn't allow me to continue.
What is the correct way to run that JavaScript function?