Skip to content Skip to sidebar Skip to footer

Javascript: Window.location.href Doesn't Redirect When Calling Function Within A Function

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 u

Solution 1:

Hitting ENTER in a text input field in an HTML form has rather different effects on different browsers.

In your case, I assume that the form is submitted on hitting ENTER. Since you haven't specified any action, the form is submitted to same page leading to a reload.

Solution 2:

You could also try adding e.preventDefault() as well as e.stopPropagation() to visitStack().

Post a Comment for "Javascript: Window.location.href Doesn't Redirect When Calling Function Within A Function"