Home > Web Front-end > H5 Tutorial > body text

Some problems encountered by WeChat H5 page

高洛峰
Release: 2017-02-09 15:13:31
Original
1619 people have browsed it

1. The cursor of the input box is not centered. Use height as a fixed value. Even setting line-height is invalid.

Solution: Do not set the height. After setting the line height with line-height, use padding. Support the height

Some problems encountered by WeChat H5 page

Some problems encountered by WeChat H5 page

2. Add audio files in WeChat, but they will not play automatically.

Solution:

function audioAutoPlay(id){    //解决微信内部无法播放音频的问题
     var audio = document.getElementById(id); 
    audio.play();  
    document.addEventListener("WeixinJSBridgeReady", function () {  
            audio.play();  
    }, false);  
    document.addEventListener("YixinJSBridgeReady", function() {  
        audio.play();  
    }, false);  
}  
    audioAutoPlay("music");
Copy after login

3. The h5 page in WeChat does not support JS refresh or jump, use

var a= Math.random() * 100;
window.location.href = window .location.href+"?id="+a;

4. The Android phone soft keyboard causes the layout to move up

Solution:

①Caused by the bottom input box bug, move the button up

②Correction through JS

function fixfixed(obj) {  

        if(document.activeElement.nodeName == 'INPUT'){
            obj.css('position', 'static');
        } else {
            obj.css('position', 'fixed');
        }
    }
Copy after login

These are currently available. After encountering new ones, continue to add

More WeChat H5 page encounters Please pay attention to the PHP Chinese website for articles related to some issues!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template