Advanced Search

Results 1 to 3 of 3

Thread: Varied Use of Script

  1. #1
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default Varied Use of Script

    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?

  2. #2
    Join Date
    May 2012
    Location
    Hitchhiking the Galaxy
    Posts
    1,013
    Thanks
    47
    Thanked 139 Times in 139 Posts
    Blog Entries
    1

    Default

    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

  3. #3
    Join Date
    Aug 2004
    Posts
    9,863
    Thanks
    3
    Thanked 959 Times in 948 Posts
    Blog Entries
    15

    Default

    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:

    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>
    If you button uses the data-sounddown attribute to play a sound, then change "mouseover" inside the script that follows to "mousedown" instead.
    DD Admin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •