Anchor link with file download

Asked

Viewed 133 times

1

I need to do something simple, but I’m not getting it.

<div class="txt-center">
<a href="software/programa.exe#final">Solicite agora</a>
</div>

I tried to do something simple, but it doesn’t work. A download link to a file for donwload, and after the download lead to the anchor, that step-by-step page of how to install the file. As it is a single page, only take the anchor.

I tried to use

Someone could help me, to be simple.

Maybe a javascript, or PHP for this?

Direct in HTML has no way?

Thanks

  • <a href="software/programa.exe" onClick='scrollTo(0,0)'>Solicite agora</a>

  • @ValdeirPsr https://stackoverflow.com/questions/5871640/why-is-using-onclick-in-html-a-bad-practice

1 answer

0


Put in attribute href tag a the file link to be downloaded:

HTML:

<div class="txt-center">
<a id="anchor" href="https://speed.hetzner.de/100MB.bin">Solicite agora</a>
</div>

<a id="target">Target...</a>

In Javascript:

Just make the references the HTML tags and in the download click call .scrollIntoView of the tag you want to give scroll.

var a = document.getElementById('anchor');
var elementoAlvo = document.getElementById('target');

a.onclick = function() { elementoAlvo.scrollIntoView(); };

Browser other questions tagged

You are not signed in. Login or sign up in order to post.