Skip to content

The problem with document.write in iframe in Edge #1718

@CrazySquirrel

Description

@CrazySquirrel

The document.write causing the error SCRIPT70: Permission denied if you use a few document.write inside iframe. This error occurs only in the Edge. In all other browsers this error is not observed.
For example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SSP-558</title>
</head>
<body>
<script>
    document.write("1");
    document.write("2");
</script>
<script>
    var iframe = document.createElement("iframe");
    iframe.width = window.outerWidth;
    iframe.height = window.outerHeight;
    iframe.onload = function () {
        var doc = iframe.contentWindow.document;
        var script = doc.createElement("script");
        script.type = "text/javascript";
        script.text = [
            'document.write("1");',
            'document.write("2");'
        ].join("");

        doc.body.appendChild(script);
    };
    document.body.appendChild(iframe);
</script>
</body>
</html>

This code will display 12 on the page and in iframe, but it cause an error and displays only 1 inside iframe in Edge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions