How do I pass a user initiated action to an iframe?

I have an audio element on a page that is currently loading inside an iframe with zero height and width. I am using postMessage from the parent page to tell the child page to play some sound.

This works fine on desktop browsers, however I am having problems with mobile browsers. (I am testing Chrome for Android, but I think iOS will have the same problem).

Mobile browsers require the play () command to be triggered by a user-initiated action. In my case, the user clicks on a button on the parent page to start the game, but it seems that when the postMessage is executed, the browser loses its trail.

Is there a way to get audio to play inside an iframe without making the page inside the iframe visible to the user?

+3


source to share





All Articles