0
votes

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";

};
1
I think the target attribute only affects the a. Trying changing location.href. (Also there is no PHP relation here, no jquery. Please only tag relevant languages) - user3783243
There doesn't appear to be any purpose your download attribute is serving in your code - Anurag Srivastava
There's no need for the _target attribute. - Salim Ibrogimov

1 Answers

-1
votes

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().