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