javascript - window.open within XMLHttpRequest onreadystatechange anon. function
<p>Here is what I'm trying to do:</p>

<pre><code>httpReq.onreadystatechange = function() {
    if (httpReq.readyState == 4) {
        if (httpReq.status == 200) {
            var response = httpReq.responseText;
            if (response == "-2") document.shortener_form.urlField.value = "";
            else {
                document.shortener_form.urlField.value = response;
                window.open("http://example.com", '_blank');
            }
        } else {
            document.shortener_form.urlField.value = "Error!";
        }
    }
};
</code></pre>

<p>The <code>window.open</code> function on line 8 is not executing. It works everywhere else, just not within that anonymous function. I'm terrible at Javascript, I've searched Google and SO however found no answer. Thanks.</p>

<p><strong>Edit:</strong> by the way, the function works everywhere else on the page and script, so I've isolated the problem to be within this anonymous function.</p>
