Open responseText on a new page

1

Is there any way to open responseText directly in a new window? I explain:

The code I use sends data to a PHP file that returns N messages. If I do the following alert(event.target.responseText); it returns me in the alert return HTML, as below:

Is there any way to open this normal HTML, even on the same page?

    
asked by anonymous 28.11.2016 / 16:59

1 answer

0

The iframe tag allows you to insert one HTML document into another. Example:

        document.getElementById('meuFrame').srcdoc = 
        "<html> \
            <body> \
                <p>Segundo documento</p> \
            </body> \
        </html>";
<html>
    <body>
        <p>Primeiro Documento</p>
        <iframe id="meuFrame" frameborder="0"></iframe>
    </body>
</html>

The attribute srcdoc (HTML5) defines the contents of the iframe directly, I believe that is your case.

Caution: Be careful with iframes content, as they can run JS just like any other page. If you do not trust the content provided for your iframe , read about the sandbox attribute.

    
28.11.2016 / 17:35