Link anchors with file download [duplicate]

1

I need to do something simple, but I can not do it.

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

I tried to do something simple, but it did not work. A download link to a file for download, 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, just take the anchor.

I tried to use

Someone could help me, to be simple thing.

Maybe a javascript, or PHP for this?

Direct in HTML does not have?

Thank you

    
asked by anonymous 26.10.2018 / 03:57

1 answer

0

Put in the href attribute of the a tag the link of the file 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 on the download click call .scrollIntoView of the tag you want to scroll.

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

a.onclick = function() { elementoAlvo.scrollIntoView(); };
    
26.10.2018 / 05:47