Trouble with iframe.

So i'm making a website that you can write html/css and js and run. The output will be displayed on a Iframe(Doing this through Jquery). The website works fine localy, but on weebly it's not working. I know it's the iframe because when I take it out the rest of my website works agian.

This is in my body

<iframe id='display'>
<!DOCTPYE html>
    <html>
        <head>
        </head>
        <body></body>
    </html>
</iframe>

And not like you need this, but here's the execute function in javascript

function runCode() {


        var target = $("#display")[0].contentWindow.document;
        target.open();
        target.close();

        var html = getHtml();
        var css = getCss();
        var js = getJs();

        $("body", target).append(html);
        $("head", target).append("<style>" + css + "</style>");
        $("head", target).append('<scr' + 'ipt type="text/javascript">' + js + '</scr' + 'ipt>');
}

Here's the log in console

footerSignup.js:1 Uncaught TypeError: Cannot set property 'footer' of undefined
        at footerSignup.js:1
        at Object.188 (footerSignup.js:1)
        at t (footerSignup.js:1)
        at Object.0 (footerSignup.js:1)
        at t (footerSignup.js:1)
        at e.0 (footerSignup.js:1)
        at footerSignup.js:1
Editor.html:783 Uncaught ReferenceError: Weebly is not defined
        at Editor.html:783
Editor.html:819 Uncaught ReferenceError: _W is not defined
        at Editor.html:819
Editor.html:842 Uncaught ReferenceError: _W is not defined
        at Editor.html:842
Editor.html:954 Uncaught ReferenceError: _W is not defined
        at Editor.html:954
        at Editor.html:984

I'm using a free weebly host right now, so there's the ad at the bottom saying something like "Create a website today". I think it might have something to do with that and trying to load it on the I frame.

1,690 Views
Message 1 of 4
Report
3 REPLIES 3

Hey there! Just to clarify things a bit, is the entire site not working with the iframe introduced, or just the frame itself?

1,679 Views
Message 5 of 4
Report

I fixed the HTML and CSS on the iframe. I had to take out the body of the iframe. Now the only problem is the JavaScript. It's not running the javascript inside the iframe but on the document as a whole. In console it says i'm using Eva(), I think that's the function. 

1,650 Views
Message 5 of 4
Report
Square

I'm not sure if this will matter, but instead of using "$" use jQuery, like this:

var target = jQuery("#display")[0].contentWindow.document;

1,646 Views
Message 5 of 4
Report
This thread has been archived and locked. Please start a new thread if you would like to continue the conversation.