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
javascript html5-audio iframe postmessage chrome-for-android


source to share


No one has answered this question yet

Check out similar questions:

2817
How can I upload files asynchronously?
2701
How do I get the values โ€‹โ€‹of a query string in JavaScript?
2414
How can I find out which radio button is selected using jQuery?
2288
How can I convert a string to boolean in JavaScript?
2284
How can I combine properties of two JavaScript objects dynamically?
2245
How do I refresh the page using jQuery?
2237
How do I pass command line arguments to a Node.js program?
1966
How can I select an element with multiple classes in jQuery?
1542
How can I print JSON using JavaScript?
960
How do I apply CSS to an iframe?



All Articles
Loading...
X
Show
Funny
Dev
Pics