1) Script Title: Dynamic Drive DHTML Scripts- Image Swap and HTML5 audio effect
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex15/domroll2.htm
3) Describe problem: Could this script run a sound automatically when a web page loads?
1) Script Title: Dynamic Drive DHTML Scripts- Image Swap and HTML5 audio effect
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex15/domroll2.htm
3) Describe problem: Could this script run a sound automatically when a web page loads?
You could modify it to play on page load, but it would be a lot easier t0 just use an audio element. You can then make it run on page load by just doing something like:
HTML Code:<audio src="audio/sample.mp3" autoplay> <!-- your audio files --> </audio>
"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program." - Linus Torvalds
Anime Views Forums
Bernie
Bernie is right, though going back to your original request, you can get the button to automatically play its sound when the page loads by first giving the button element an ID attribute to identify it, then following it, artificially triggering the event handler that plays the sound. For example:
If you button uses the data-sounddown attribute to play a sound, then change "mouseover" inside the script that follows to "mousedown" instead.Code:<img id="test" src="original.jpg" data-srcover="over.jpg" data-soundover="whistle.mp3, whistle.ogg, whistle.wav"> <script> $(window).bind('load', function(){ // when page loads $('#test').trigger('mouseover') // trigger "mouseover" event of #test element }) </script>
DD Admin
Bookmarks