1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

JS to force auto-playing in modern browsers

Discussion in 'JavaScript' started by abrodski, Jul 22, 2019.

  1. #1
    Is there a way to use JS to bypass a recent limitation in modern browsers to autoplay music?
    I activated an autoplay in a Joomla music player plugin and I also used JS code via Custom HTML module
    <script type="text/javascript">
    var source = 'https://apostasia.ru/1.mp3';
    var audio = new Audio();
    audio.addEventListener('load', function() {
    }, true);
    audio.src = source;
    audio.autoplay = true;
    Code (JavaScript):

    abrodski, Jul 22, 2019 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Likes Received:
    Best Answers:
    Trophy Points:
    Are you just TRYING to piss off visitors to your pages? You do know that's blocked FOR A REASON, right?

    Though a good start might be just using an AUDIO tag instead of wasting JavaScript on something that doesn't require scripting.
    deathshadow, Jul 25, 2019 IP