View Full Version : sound code not working

08-10-2004, 09:23 PM
hi everyone,
i'm a newbie to javascript and desperate to get this to work.
here www.femius.ch/index_new.htm i have used two pieces of code; one to play sound when you click on the song titles as well as the thumbnails, and one to change the picture in the righthand box (when u click song titles). when i use these codes seperately they both work fine, however once i put them on the same link, the sound code stops functioning. As you can see by clicking on the song titles (pic changes, sound does not play). however the same code works fine when u click on the thumbnails (the pic changing code is not used on it). I'd really appreciate any help.
Thanks a million!
Here is the sound code:
<script LANGUAGE="JavaScript"><!--
// Preload and play audio files with event handler (MouseOver sound)
// designed by JavaScript Archive, (c)1999
// Get more free javascripts at http://jsarchive.8m.com

var aySound = new Array();
// Below: source for sound files to be preloaded

// DO NOT edit below this line
document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;

function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
var Str = '';
for (i=0;i<aySound.length;i++)
Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (IE) auEmb.innerHTML = Str;
else {
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = auCtrl;
function auCtrl(whSound,play) {
if (IE) this.src = play? aySound[whSound]:'';
else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
function playSound(whSound) { if (window.auCon) auCon.control(whSound,true); }
function stopSound(whSound) { if (window.auCon) auCon.control(whSound,false); }

and here the pic changing code:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

// canManipulateImages - check if the browser we're using can do
// clever stuff with document images.

function canManipulateImages() {
if (document.images)
return true;
return false;

// loadPosterImage

function loadPosterImage(imageURL) {
if (gImageCapableBrowser) {
document.imagePoster.src = imageURL;
return false;
else {
return true;

// gImageCapableBrowser - is this browser hip to images? Set up
// a global variable so that we don't have to keep calling a function
// (useful if the function becomes costly to compute).

gImageCapableBrowser = canManipulateImages();

// -->

and the link to activate them:
<img src="img/01.gif" alt="01 Beat Of My Heart" width="30" height="9"> <a href="javascript:playSound(0);" onClick="return(loadPosterImage('img/01.jpg'))" class="tracks">Beat Of My Heart</a>


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum