0

So, I want to make a section of my website called "Video of the day". I wanted to have a public google doc that I just change the link in every day to have the youtube video or whatnot video show up on my website. I would have the embedded google doc there, just hidden by css. I want to have another iframe that links to the link I put into the google doc. I thought I had it, but my javascript gave me this error:

Home.html:58 Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
    at readdoc (file:///C:/Users/GUNDERSON/Desktop/Coding/Web%20Development/School/Project%201/Home.html:58:67)
    at HTMLButtonElement.onclick (file:///C:/Users/GUNDERSON/Desktop/Coding/Web%20Development/School/Project%201/Home.html:36:33)

Here is the iframe:

<iframe id="docembed" src="https://docs.google.com/document/d/e/2PACX-1vQTyqr6dSS6bGaCir11QJkdZciFMt6m23Hw1HOG6K8ZOJDi7jjB_yYy37Y0Qd4myeyND8MIGLlpd2o-/pub?embedded=true"></iframe>

And lastly my javascript:

function readdoc() {
            
var iframe = document.getElementById("docembed").contentWindow.document.body.innerHTML;
                alert(iframe);
                
            }

Note: I tried this, but it kept on saying undefined:

$("#testbutton").click(function() {
            
                $("#docembed").contents().find("#contents").removeClass("hidden");
                alert($("#docembed").contents().find("#document").html());
                
            });

0 Answers0