The Mid-Autumn festival near, Whim want to do a mobile phone-side greeting card, the previous contact with less mobile, although it is a simple greeting card, in fact, quite a lot of pits, briefly speaking in the process of making greeting cards encountered the pit:
A: Mobile screen size can not be counted as body size, because the phone browser head has a URL navigation and so on, the bottom also has left white, should go out this part;
Two: Audio background music is not automatically play, no matter how debugging JS are useless, after a lot of verification, incredibly mobile has done a limit, must be user interaction to trigger, the online solution is mostly through the Touchstart event;
<audio id= "Myaudio" > <source src= "/static/warn.mp3" type= "Audio/mpeg" ></audio><script >var tt;function Audioplay () { document.getElementById ("Myaudio"). Play (); tt = SetTimeout (Audioplay, 5000);} function Audioload () { document.getElementById ("Myaudio"). Pause ();} </script>//Trigger play Audioplay ();//Clear timed task cleartimeout (TT);
Mobile Audio Auto-play problem