www.webdeveloper.com
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    23

    Question onClick play music

    I have an image i would like to link so that when it is clicked a music file is played.

    any ideas how i can go about this without opening a new window?

  2. #2
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Something like this? (Untested code.)


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en-US">
    <head><title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    </head>
    <body>
    <p><img src="image.gif" alt="Image description - Play music" onclick="document.getElementById('embMusic').src='music.mp3';"></p>
    <p><embed src="" autostart="true"></embed></p>
    </body></html>


    [J]ona
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

  3. #3
    Join Date
    Jul 2003
    Posts
    23
    does "<embed src="" autostart="true"></embed>" need to be named embMusic?

  4. #4
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Oh man, I am tired. lol. Okay, you're right. id="embMusic" should be added to it. If it doesn't work, turn EMBED into BGSOUND. Take a look at this script that I made a while ago--it should help you.

    [J]ona
    Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

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
HTML5 Development Center



Recent Articles