Play a Message in a Gong board
| Board: | BBC - Learning English |
| Subject: | Mystery illness |
The Relevant JavaScript and HTML Code
This example is created using a Gong applet with a few HTML components. The Gong applet is hidden visually in the page but it remains working in the background.
In order to start a voice playback JavaScript is used to send a request to the Gong applet. This is done by using a function called 'gongPlay' given in the 'gong.js' library. The library simplifies the process by handling all required communication with the applet using the scripting interface. Similarly to stop a playback a function called 'gongStop' is executed when the user clicks on the stop button.
...
<script type="text/javascript" src="gong.js"></script>
<script type="text/javascript">
<!--
function play() {
...
gongPlay(document.getElementById("applet"));
...
}
function stop() {
...
gongStop(document.getElementById("applet"));
...
}
// -->
</script>
...
<input type="button" value="Play" onclick="play()" />
<input type="button" value="Stop" onclick="stop()" />
...
<applet id="applet" ...>...</applet>
...