Javascript: window.location.href doesn't redirect when calling function within a function
<p>window.location.href redirects the browser to stackoverflow.com when the button is clicked, but does not when hitting "Enter" in the input textfield, despite both event listeners using the same function visitStack.</p>

<p>If this helps, changing the form tags to div tags somehow makes it work, but it's not semantic, of course.</p>

<p>Changing "keydown" in the last line to "click", and moving visitStack(e) immediately within keyDownTextField(e), make it work too.</p>

<p>So keydown and/or form tags seem to be the culprits here, but I'm not sure.</p>

<pre><code>&lt;form&gt;
&lt;input id="iamtext" type="text" /&gt;
&lt;input id="gobutton" type="button" value="Overflow" /&gt;              
&lt;/form&gt;


&lt;script type="text/javascript"&gt;
    document.getElementById("gobutton").addEventListener("click", visitStack, false);

    function visitStack(e) {
        e.stopPropagation();                
        window.location.href = "http://www.stackoverflow.com";
    }

    function keyDownTextField(e) {
        var keyCode = e.keyCode;
        if(keyCode==13) {
            alert("Entered!");
            visitStack(e);
        }
    }

    document.getElementById("iamtext").addEventListener("keydown", keyDownTextField, false);
&lt;/script&gt;
</code></pre>
