2

I need to create a webpage as part of a project, and I wanted to add a sound effect that plays when the Facebook like button is pressed. Is there any way of doing this? I've tried adding onclick="document.getElementById('whisper').play();" to the iframe tag it came with, and added <audio id="whisper" src="whisper.mp3" preload="auto"></audio> afterwards, but it didn't result in anything. This worked with a previous button in my webpage, so am I doing something wrong or is there something else I should be doing? Ideally, I'd like to accomplish this using HTML tags, but javascript is fine as well.

Here is the whole section with the iframe tag:

<section class="contact">
                                    <header>
                                        <h3>It wouldn't kill you to give us a like on Facebook</h3>
                                    </header>
                                    <p>...Or would it?</p>
                                    <iframe src="https://www.facebook.com/plugins/like.php?href=https%3A%2F%2F(**link here**)&width=450&layout=standard&action=like&size=small&show_faces=true&share=true&height=80&appId" width="450" height="80" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>

                                </section>

There is a link to the page that's in there; I'm just not including it here for privacy reasons.

Apologies if I'm not being very specific and/or helpful; I've only got about 3 months of experience with HTML so far :)

1 Answers1

0

There was a way earlier with a specific event called right after hitting the like button, but it is deprecated. So there is no way to detect Like Button hits anymore.

https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v5.0 (It was the edge_create event)

More information: Facebook like callback event using edge.create is not working

andyrandy
  • 72,880
  • 8
  • 113
  • 130