rewrite js
This commit is contained in:
parent
2996642ee5
commit
f0ef814c1a
1 changed files with 13 additions and 8 deletions
21
index.html
21
index.html
|
@ -88,22 +88,27 @@
|
|||
</section>
|
||||
</main>
|
||||
|
||||
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
let link = document.getElementById('soundlink');
|
||||
let miku = document.getElementById('miku');
|
||||
if (typeof miku.play == 'function') {
|
||||
function playMiku(e) {
|
||||
miku.play();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
link.href = '#';
|
||||
link.addEventListener('click', playMiku);
|
||||
function play(e) {
|
||||
e.preventDefault();
|
||||
miku.play();
|
||||
}
|
||||
|
||||
// attempt to ensure at least one of the sources is recognised
|
||||
// (and that <audio> is supported)
|
||||
if (!isNaN(miku.duration)) {
|
||||
link.href = '#listen';
|
||||
link.addEventListener('click', play);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<!--
|
||||
- mutant standard emoji by @Dzuque: 👉 https://mutant.tech 👈
|
||||
(licensed cc-by-nc-sa 4.0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue