I am trying to preload some sounds for a website I am working on... Originally I used the embed tag but that caused problems in Opera and did not validate... So I've switched to the object tag which now works in everything except IE8...

<object id="sound_lock" class="embedded" data="sounds/iphone/system/iphone_sound_lock.wav">
<param name="autostart" value="false" />
</object>

I had to put in a class to hide the sound files because tey were appearing with controls in Opera...

.embedded { visibility: hidden; }

Lastly here is the javascript code that plays the sound when required... Works in latest FF, Opera, Safari and Chrome but not in IE8... IE8 generates an 'object doesn't support this property or method' error...

var thisSound=document.getElementById(soundObj);
thisSound.Play();

I'm assuming this is because IE8 can't get the id from the object tag but can't find a work around... I want to make sure all the code validates appropriately so I am trying to avoid the embed tag...

Hope someone can help :)

Recommended Answers

All 6 Replies

Are you using IE8 on Window 7? If so, the IE8 has some kind of problem playing sound. You could google and find how others discuss about this issue.

This is on Windows XP. I can make it work if I use embed tags instead of object tags. However that is not valid code and I'd rather not.

Haven't had much luck after hours if googling but I'll keep trying

Thanks Kyler I'll check it out :)

IE sometimes(grin) needs a src parameter to understand the location.

<object id="sound_lock" type="audio/x-wav" class="embedded"  data="sounds/iphone/system/iphone_sound_lock.wav" />
<param name="autostart" value="false" />
<param name="src" value="sounds/iphone/system/iphone_sound_lock.wav" />
</object>

Ie sometimes need help to find its bum

Thanks almostbob I'll try that out when I finish work... Fingers crossed :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.