Solution 1 :

in the <a>, remove the href, add `onclick=”go()”, and in a script, add:

function go() {
  open("http://www.google.com", "_blank");
  location.href = "http://mail.google.com";
}

Good luck!
if you are familiar with event listeners, you could use that instead to call go().

Problem :

I want to open a success page in a new tab after clicking on the download link, but target _blank not working with download attribute. Please Help Me……

Button HTML

<a class="btn download-btn" id="myButton" href="https://www.uiuxstream.com/download/404-error-page-not-found-design-html.html" target="_blank" download>Download</a>

JavaScript

<script type="text/javascript">

    document.getElementById("myButton").onclick = function () {
    location.href = "/demo/thank-you-for-downloading.php";

};

Comments

Comment posted by user3783243

I think the

Comment posted by How to add target=”_blank” to JavaScript window.location?

Does this answer your question?

Comment posted by Anurag Srivastava

There doesn’t appear to be any purpose your

Comment posted by Salim Ibrohimi

There’s no need for the _target attribute.

Comment posted by iAmOren

So, is this a good answer? If so, please select and up-vote it – thanks!

By