0
I have a folder, in which covers several videos with equal names and different formats:
https://sites.google.com/site/mplayerplugin/repositorio/monstros_sa_2.webm
https://sites.google.com/site/mplayerplugin/repositorio/monstros_sa_2.mp4
https://sites.google.com/site/mplayerplugin/repositorio/big_buck_bunny.webm
https://sites.google.com/site/mplayerplugin/repositorio/big_buck_bunny.mp4
And so on and so forth ...
As I will give two download options, for 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 we can see, all links in the HTML document are in nature
*.webm
.What remains is to exchange
*.webm
for*.mp4
, to the link<a id='mp4'>MP4</a>
.
I thought I’d work with RegExp
, something I still can’t work out.
Someone has a logic to show me how to get around this obstacle?
seuLink.replace('.webm', '.mp4');
– andrepaulo
@andrepaulo Huuummm! truth didn’t even remind me of this function at the time you brought me to memory. I’m gonna test it out and I’m gonna go back to check if it worked properly for the purpose. =)
– Diego Henrique
I did not understand when Voce will use Mp4 and when it will use WEBM... at that time Voce converts the name ... assuming that Voce has two links.. a para WEBM e uma pra MP4... no de mp4 Voce tem que rodar um metodo que pega o link e troca para . mp4 .. since the same is coming with the . webm
– andrepaulo