Window.open () returns null in IE11 on open

In IE on Windows 10 with default settings, if I run window.open()

against an external internet site from a page on my local computer or on a server on my local network, I get null

.

See my story below. This does not happen in IE on Windows 7 or Google Chrome.

Interestingly, if I enable "Enable Protected Mode" for the intranet zone (so that Protected Mode is the same in the intranet zone and the Internet zone), the problem goes away. However, I need this to work without requiring users to do so.

I have not found clear Microsoft documentation that explains this behavior. I raised a question about this on the EdgeHTML issues site, but wanted to see if the SO community knows why this is happening.

Thank!

<!DOCTYPE HTML>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <script>
        var popupWindow = null;

        function openWindow() {
            popupWindow = window.open('http://microsoft.com', '_blank', 'left=100;top=100;height=100;width=100');
        }

        function checkWindowStatus() {
            if (popupWindow) {
                document.getElementById('status').innerHTML += '- Truthy reference. Closed? ' + popupWindow.closed + '</br>';
            } else {
                document.getElementById('status').innerHTML += '- Falsy reference: ' + popupWindow + '</br>';
            }
        }
    </script>
</head>

<body>
    <h2>Popup Issue</h2>
    <button onclick="openWindow()">Open Window</button>
    <button onclick="checkWindowStatus()">Check Window Status</button>
    <button onclick="popupWindow.close()">Close Window</button>
    <p id="status"></p>
</body>

</html>

      

+3


source to share


1 answer


Protected mode seems to prevent a new window from opening outside the current domain, so you can try opening a window with a blank page after updating the location.



<script>
    var popupWindow = null;

    function openWindow() {
        popupWindow = window.open('', '_blank', 'left=100;top=100;height=100;width=100');
        popupWindow.location = 'http://microsoft.com';
    }

    function checkWindowStatus() {
        if (popupWindow) {
            document.getElementById('status').innerHTML += '- Truthy reference. Closed? ' + popupWindow.closed + '</br>';
        } else {
            document.getElementById('status').innerHTML += '- Falsy reference: ' + popupWindow + '</br>';
        }
    }
</script>

      

+1


source







All Articles