Solution 1 :

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

function go() {
  open("", "_blank");
  location.href = "";

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="" target="_blank" download>Download</a>


<script type="text/javascript">

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



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!