Here is a simple javascript which you can use to play a backgroung music on your html pages. In IE it works fine and for FireFox I just happened to host it locally for testing because the 'else' part in the script does not work with "file:///" protocol used in FF. So if you find an answer for that issue please let me know too.. Enjoy.!!
<script language="javascript" type="text/javascript">
if (navigator.appName == "Microsoft Internet Explorer")
{
document.write('<bgsound src="path/filename" loop="false">');
}
else
{
document.write('<embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
Name="MediaPlayer"
src="path/filename"
autostart="true"
showstatusbar="0"
showcontrols="0"
showdisplay="0"
volume="1"
height="1"
width="1"
loop="false">');
}
if (navigator.appName == "Microsoft Internet Explorer")
{
document.write('<bgsound src="path/filename" loop="false">');
}
else
{
document.write('<embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
Name="MediaPlayer"
src="path/filename"
autostart="true"
showstatusbar="0"
showcontrols="0"
showdisplay="0"
volume="1"
height="1"
width="1"
loop="false">');
}
src="path/filename", this path can be an actual or a relative path to the file. And the filename is including the extension. I tested it using a .mp3 file.
No comments:
Post a Comment