简体   繁体   中英

Playing audio without audio tag

Is it possible to play audio without the audio tag and just using javascript?

I'm injecting script through a tinyMce editor since I don't have access to a site's backend and it doesn't support the audio tag for a client. She just wants a simple sound when you hover over an image. I have it all setup however, the restriction of not having an audio tag is tripping me up.

I am hosting the audio files on a remote site since I cannot upload them here. Is there perhaps a way to leverage that remote site? I've never run into this issue before and can't really find anything on it.

You can use this:

mySound = new Audio('sound.mp3');
mySound.play()

Here is a link to its specification - HTMLAudioElement

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM