how can I play a sound clip on page load?

15,002

Solution 1

Through simple HTML.

<object>
<param name="autostart" value="true">
<param name="src" value="sound.mp3">
<param name="autoplay" value="true"> 
<param name="controller" value="true">
<embed src="sound.mp3" controller="true" autoplay="true" autostart="True" type="audio/mp3" />
</object>

Solution 2

you can pull this off with straight html

http://www.webreference.com/js/column20/bgsound.html

or

http://www.htmlcodetutorial.com/sounds/_BGSOUND.html

I think wav, mid, and mp3 are supported

Solution 3

You can also combine the answers from premiso and CheeseConQueso with HTML5 audio tag: https://developer.mozilla.org/en/using_audio_and_video_in_firefox

Share:
15,002
nectar
Author by

nectar

Updated on June 04, 2022

Comments

  • nectar
    nectar almost 2 years

    how can I play a sound clip on page load?Is there any javascript or jquery to do that?I am creating my page in php.

  • Jin Yong
    Jin Yong over 11 years
    I applied this code into my page, but have no sound play .. :(