<script language="JavaScript" type="text/JavaScript">
// generate random number 1-3
Num = Math.round(Math.random() * 3);
document.write(Num);
//pick song to play based on number generated
if (Num = 1){
document.getElementById('embMusic').src='iwantyou.mp3';
}
else
{
document.write("you suck");
}
</script>
<html>
<embed id="embMusic" src="" autostart="true"></embed></html>
when i bring this up my browser tells me i have to install plugins? i know i already have flash or at least WMP... what gives?
As far as I know, you can't embed mp3 like that. Use <audio>
tag instead.
Example:
<audio id="embMusic" src="iwantyou.mp3"></audio>
And then from javascript:
document.getElementById('embMusic').play();
Or you can do it without the <audio>
element, just with javascript, like this:
var audio = new Audio();
audio.src = "iwantyou.mp3";
audio.play();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.