There are many same questions here. I tried all solutions - nothing helps.
I want to open new page in some tab with javascript. Here is my HTML:
<
You've got this onclick
attribute on an <input type="image">
element. Image inputs are effectively submit
buttons. When you click it, it is activated, and the form is submitted. When a form is submitted, it cancels any ongoing HTTP requests, such as your window.location
call.
So you need to prevent the form submission from going ahead.
The quick and dirty way to do this is to return false
from your event handler. Something like this:
onclick="return testUrl()"
With the JS:
function testUrl()
{
window.location = "content.html";
return false;
}
The prettier way to do this would be to bind your event handlers with Javascript and use event.preventDefault
.