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 5995333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:56:42+00:00 2026-05-22T23:56:42+00:00

I want to understand how to implement HTML5 <audio> fallback using Javascript… i.e. I

  • 0

I want to understand how to implement HTML5 <audio> fallback using Javascript…

i.e. I have a div on my page, to which , I dynamically append <embed> tag when “Play audio” link is clicked currently..
i.e. I currently use

function playSound(audioUrl)
{
var x = document.getElementById("playAudio");
x.innerHTML = '<EMBED src="'+audioUrl+'" autostart=true loop=false volume=100 hidden=true>';
} 

I want to have the same thing implemented using the HTML5 <audio> tag, But want to fallback to embed when HTML5 audio tag is not supported. How can I implement the same using JS given that the Audio URL is kind of dynamic ?

My intention is it should work on older as well as newer browsers..like IE6,7,8; FF 3,4; Chrome; Safari 4,5 on MAC, Safari on iPad..

  • 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-05-22T23:56:43+00:00Added an answer on May 22, 2026 at 11:56 pm

    You could use Modernizr to detect audio support.

    If you don’t want to include that library for a simple thing, this should do it…

    var audioSupport = document.createElement('audio').hasOwnProperty('src');
    

    jsFiddle.

    So that would be…

    function playSound(audioUrl) {
        var audioSupport = document.createElement('audio').hasOwnProperty('src'),
            x = document.getElementById("playAudio");
    
        if (audioSupport) {
            var audio = document.createElement('audio');
            audio.src = audioUrl;
            x.appendChild(audio);
            audio.play();
        } else {
            // Or you could use proper DOM methods...
            x.innerHTML = '<EMBED src="' + audioUrl + '" autostart=true loop=false volume=100 hidden=true>';
        }
    }
    

    jsFiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this javascript function I am trying to understand. I don't know if
I want to implement a properties table in jtable (swing). I want to have
I am using the ScintillaNET wrapper for the Scintilla control and want to implement
I'm using devise invitable: gem on github I want to implement controller inheritance, so
I want to implement and understand the concept of marshalling over my own rpc
I have an 'intro' page that I am creating and I want to click
I'm reading Paul Graham's A Plan for Spam and want to understand it better
This is probably an easy question, but I want to understand better how Apache
As far as I understand, if I want to get my database under source
Yes, I do understand the difference between them. What I want to know is:

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.