JSFiddle - React, Tailwind, and code Playground
by max zwart
HTML
<script>
var html5_audiotypes={
"mp3": "audio/mpeg",
"mp4": "audio/mp4",
"ogg": "audio/ogg",
"wav": "audio/wav"
}
function createsoundbite(sound){
var html5audio=document.createElement('audio')
if (html5audio.canPlayType){ //check support for HTML5 audio
for (var i=0; i<arguments.length; i++){
var sourceel=document.createElement('source')
sourceel.setAttribute('src', arguments[i])
if (arguments[i].match(/\.(\w+)$/i))
sourceel.setAttribute('type', html5_audiotypes[RegExp.$1])
html5audio.appendChild(sourceel)
}
html5audio.load()
html5audio.playclip=function(){
html5audio.pause()
html5audio.currentTime=0
html5audio.play()
}
return html5audio
}
else{
return {playclip:function(){throw new Error("Your browser doesn't support HTML5 audio unfortunately")}}
}
}
var clicksound1=createsoundbite("https://ia601500.us.archive.org/2/items/Valerij_meladze_-_parallelnie_zf.fm/valerij_meladze_-_parallelnie_%28zf.fm%29.mp3")
var clicksound2=createsoundbite("https://ia601506.us.archive.org/22/items/Sogdiana_-_na_vostok_ot_edema_zvukoff.ru/sogdiana_-_na_vostok_ot_edema_%28zvukoff.ru%29.mp3")
</script>
<a nohref onclick="clicksound1.playclip()" style="cursor:pointer;" title="Facebook" target="_blank">
<img src="https://d2fi4ri5dhpqd1.cloudfront.net/public/resources/social-networks-icon-sets/circle-dark-gray/facebook.png" alt="Facebook" width="32" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: none;height: auto;float: none;max-width: 32px !important">
</a>
<a nohref onclick="clicksound2.playclip()" style="cursor:pointer;" title="Vkontakte" target="_blank">
<img src="https://d2fi4ri5dhpqd1.cloudfront.net/public/resources/social-networks-icon-sets/circle-dark-gray/vkontakte@2x.png" alt="Vkontakte" title="Vkontakte" width="32" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: none;height: auto;float: none;max-width: 32px !important"...