Examples of Popups with Audio
via the overlibmws DHTML Popup Library maintained by Foteos Macrides at Macrides Web Services Discuss these examples, seek help, and offer suggestions for audio support via the overlibmws Support Group. These examples work best on broadband, but do work on dialup, and not badly once the audio files are in cache. |
I love my Harley. Meep me. Greek dances. |
The first and second examples play short audio files while the user hovers over the link, whereas the third example plays a lengthy audio file with display of a STICKY popup.. Although these examples use audio files with novelty sounds or music, the procedures also can be used with audio files which "speak" the content of displayed DHTML popups, to increase their accessibility beyond the means disussed in the support document on keyboard-invoked popups. |
Here is the relevant javascript code and HTML markup: |
As a supplement to the overDiv positioned div for the visual display of popups, we declare an audioDiv positioned div for the concomittant audio presentations: |
<div id="audioDiv" style="position:absolute; visibility:hidden;
z-index:0;"></div>
|
It should be a direct child of the body (i.e., following the body start tag and not
encased in any other container element).
We then include markup which helps to "pre-load" the lengthy .mp3 audio file and the image for the popup of the third example: |
<div id="GreekDancesDiv" style="position:absolute; visibility:visible; z-index:0;
<script type="text/javascript">
|
Then we use a "back door" strategy of also defining (via an imported .js file) the object elements (or embed elements for old versions of Firefox) as string variables, with new name and id strings so that they remain unique across elements in the document, and with the autostart attribute set to true: |
var harl = (!OLgek || OLgek>=20100101)?
|
so that we can play an audio file simply by loading the corresponding string variable as HTML into our audioDiv postioned div. |
Now we can define a playIt() function which manipulates these strings and loads our audioDiv: |
function playIt(whichsound) {
|
It has a required first argument which is either the name of an embed string variable (in this document, for our .mp3 audio files). |
We also define a stopIt() function: |
function stopIt(){
|
which we call onmouseout (together with an nd call) if the popup and audio were called onmouseover and the popup is not STICKY. For STICKY popups, which are closed via cClick calls, e.g., by the Close link in the CAPTION, we create a replacement which daisy-chains it to stopIt: |
var cClickOld = cClick;
|
Note that we use the replacement cClick in the body start tag: |
<body onunload="cClick();" onresize="cClick();">
|
to ensure that any audio associated with any open STICKY is terminated on leaving or resizing the current document. We still can simply minimize the current window and continue listening to the audio of a STICKY popup while working in another window. |
If we had secondary popups with audio, we correspondingly would define and use an audioDiv2 positioned div, and a playIt2, a stopIt2, and a replacement cClick2 function to use in conjunction with overlib2 and nd2 calls. |
|
We now are ready to make the calls for our popups with audio: |
|
I love my <a
|
|
<a
|
|
Greek <a
|
|
Use your browser's View Source option to see the javascript code, HTML markup, and CSS rules directly. |
|
|
Copyright Foteos Macrides 2002-2011. All rights reserved. |
|
|