D
D
damarkuzz2020-10-27 20:06:04
JavaScript
damarkuzz, 2020-10-27 20:06:04

How to stop SpeechSynthesisUtterance text from being spoken when navigating to another page?

How can I make sure that after voicing by the method SpeechSynthesisUtterance, when moving to another page in the same window, the voicing of the text stops?

<button class="let-speak" onclick="speek();">Произнести вслух</button>
<input id="text" value="">

    <script>
    function speek() {
        window.speechSynthesis.speak(new SpeechSynthesisUtterance(document.getElementById("text").value))        
    }
    </script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nshmyrev, 2020-11-05
@nshmyrev

window.speechSynthesis.cancel() ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question