Jump to content


Javascript for all browsers


2 replies to this topic

#1 _*Creative Insanity_*

  • Guests

Posted 27 March 2007 - 10:57 PM

I have the script below, which is a mouseover sound preview but it only works in IE.
Is there a way to get it to work in FF as well. I have tried many things and nothing worked.

function playsound(soundfile){

if (document.all && document.getElementById){

document.getElementById("soundeffect").src=""

document.getElementById("soundeffect").src=soundfile

}

}



function bindsound(tag, soundfile, masterElement){

if (!window.event) return

var source=event.srcElement

while (source!=masterElement && source.tagName!="HTML"){

if (source.tagName==tag.toUpperCase()){

playsound(soundfile)

break

}

source=source.parentElement

}

}
Ta muchly

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 29 March 2007 - 09:08 PM

function playsound(soundfile){
	if (document.all && document.getElementById){
		document.getElementById("soundeffect").src=soundfile;
	}
}



function bindsound(tag, soundfile, masterElement){
	if (!window.event) return;
	var source;
	if(event.target){
		source = event.target;
	}else if(event.srcElement){
		source = event.srcElement;
	}

	while (source!=masterElement && source.tagName!="HTML"){
		if (source.tagName==tag.toUpperCase()){
			playsound(soundfile);
			break;
		}

		source=source.parentElement;
		}
}
I don't know anything about playing sound in browsers, but i do know quirksmode.org knows a lot about event properties.

That's where i'm assuming the problem is, give it a try and lemme know :D

#3 _*Creative Insanity_*

  • Guests

Posted 29 March 2007 - 10:17 PM

Thanks for the help rc but alas nothing seems to work.
This has been a 2 month headache.
Guess I will get there one day.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users