Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8972733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:17:15+00:00 2026-06-15T18:17:15+00:00

Here is a small html file which creates a timer image and plays a

  • 0

Here is a small html file which creates a timer image and plays a timer music when I click it.

<html>
    <head>
        <script language="javascript" type="text/javascript">
            function playSound(soundfile) {
                document.getElementById("dummy").innerHTML = "<embed src=\"" + soundfile + "\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
            }
        </script>
    </head>
    <body>
        <table width="100%" height="100%">
            <tr>
                <td align="center" valign="middle">
                    <a href="#" onclick="playSound('timer.mp3');">
                        <img src="timer.png"/>
                    </a>
                </td>
            </tr>
        </table>
        <span id="dummy"></span>
    </body>
</html>

I am new to JavaScript but here is what I want:

When the user click the image the music should be played non-stop until the user clicks the image again.

How do I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:17:17+00:00Added an answer on June 15, 2026 at 6:17 pm
    <audio id="player" controls="controls"></audio>     Remove "control" if you don't
    <button onClick="playFile('timer.mp3')">Play/Stop</button>            need it.
    
    var playing = false;                                    //pre set plaing to false
    function playFile(n){
        var player = document.getElementById("player");     //get the <audio>
        player.src = n;                                     //set the url
        playing = !playing;                                 //flip the status
        playing ? player.play(): player.stop();             //play/stop
        player.addEventListener("ended", function(){        //When ended,
            player.play();                                  //play again
            //do other stuff
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have small jquery script which allows me to load external html content by
Here is my small script $item=Inception; $query=SELECT * FROM items WHERE item = '{$item}'
i have a small problem here which i cannot fix,This post goes through but
Small problem here I want to make a small fb app which show different
I wrote a small PHP script which does a branding on a present PDF
I made the following small Javascript script to enable some form elements on my
Here is small example: A <- c(1,1,1,1, 0, 0, 0, 2,2,2) B <- c(1,1,1,1,
Here a small piece of code for testing and explain the problem. I have
Here's a small fiddle for my issue: http://jsfiddle.net/Yc9WY/52/ Essentially, one box of items is
here is a small peice off code that i wrote. But I am not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.