I have a folder, which contains several videos with different names and different formats:
And so on ...
How do I give two download options to visitors. I have to change one of them. See:
function baixar(arquivo) {
var get = document.getElementById("download").getElementsByTagName('a');
for(var i in get) {
get[i].href = arquivo;
}
}
<a href="https://sites.google.com/site/mplayerplugin/repositorio/monstros_sa_2.webm" onclick="baixar(this); return false">A</a>
<a href="https://sites.google.com/site/mplayerplugin/repositorio/madagascar_2.webm" onclick="baixar(this); return false">B</a>
<a href="https://sites.google.com/site/mplayerplugin/repositorio/big_buck_bunny.webm" onclick="baixar(this); return false">C</a>
<a href="https://sites.google.com/site/mplayerplugin/repositorio/procurando_dory.webm" onclick="baixar(this); return false">D</a>
<hr>
<span id="download">
<a id='mp4'>MP4</a> | <a id='webm'>WEBM</a>
</span>
As you can see, all links in the HTML document are
*.webm
.What's missing is to switch from
*.webm
to*.mp4
, to the<a id='mp4'>MP4</a>
link.
I thought about working with RegExp
, something I still can not work out.
Does anyone have a logic to show me how I can work around this problem?