ArbolOne said:
can anyone tell me what is wrong with this syntax?
document.writeln('<bgsound src="' + soundfile +'" loop=1> +
volume=v>');
Everything.
1. Use document.write() instead.
2. The `bgsound' element is proprietary, obsolete, and unnecessary.
You must have been getting this from an obsolete or erroneous
tutorial or Web site.
3. Suppose the value of `soundfile' is "foo", this would generate
<bgsound src="foo" loop=1> + volume=v>
Probably you are (not) looking for this:
document.write('<bgsound src="' + soundfile + '" loop=1'
+ 'volume="' + v + '">');
Again, that is recommended against from the HTML point of view. Use instead:
document.write([
'<object data="' + soundfile + '">',
' <param name="FileName" value="' + soundfile + '">',
' <param name="URL" value="' + soundfile + '">',
' <param name="playCount" value="1">',
' <param name="volume" value="' + v + '">',
'<\/object>'
].join("\n"));
The `param' elements should take care of Microsoft Media Player 9+ support,
but you might have to branch with a `clsid' attribute for the `object'
element in order to avoid ActiveX warnings (see
<
http://msdn.microsoft.com/en-us/library/aa393200(VS.85).aspx>). The only
alternative I know is the proprietary `embed' element.
That said, avoid using background sounds/music on Web sites as they will
likely annoy users. Notable exceptions include those where the background
sound or music is probably important for user experience, such as the proper
background sound in a simulation or the newest title playing on a music
group's Web site. Be sure to provide a way to shut it all sounds off, though.
HTH
PointedEars