|music: "Hazy Shade of Winter" by Paul Simon|
A "background sound" is a sound that starts to play automatically when the web page is loaded.
Before you go any further, think hard: Do you really want to do this? Background sounds have a way of annoying people. There someone is, happily surfing the net, when suddenly their computer starts playing music for everyone to hear, perhaps everyone in the office area, who are now finding out that our formerly happy surfer isn't really working. That's not to say that background sounds are never a good idea... you may have noticed that we use one on this page. It just seemed appropriate for a page about sounds on web pages.
Now, assuming you've thought through the consequences of your actions, let's talk about how to put a background sound on your page. Unfortunately the browser industry and standards committees have not settled on a standard way of accomplishing this. Netscape allows background sounds through use of the
The code says this:
- If the current browser is MSIE then write out a
- Else, if the current browser is Netscape then write out an
- Then in the
section, browsers that don't understand scripting will see the
tag. Several browsers that don't understand scripting do understand
. Also, browsers that have scripting turned off but do understand
will also see this tag. Of course, browsers that have scripting turned off but don't understand
will have no sound at all. Again, that's the price being paid for lack of standards. At least they won't fail with an ugly error message.
That's kind of complicated, isn't it? Well, that's the problem with this sort of kludge: you have to try to anticipate all the situations and avoid the nasty ones. Hopefully in the foreseeable future the browser makers will correct this problem.