Android Browser loading height rendering problem for pictures

Source: Internet
Author: User

Today in the development of Youdao Chinese Dictionary Mobile version of the encounter a very strange problem.

When accessed on Android devices, always found that the bottom background color can not be fully rendered out of the situation (sometimes normal, a little while the appearance of a moment, the iphone device is also completely OK), is half the background, and half is not ...

After a closer look, I found that when I opened the Web page, I showed a small picture of the head and a caption, a button at the bottom, and a larger image in the middle, with a loading process.

OK, suspect that the picture has not been loaded, resulting in a height calculation error, to the bottom of the background when the loaded block is no color ...

Then use the $ (window). Load () function to fix it!

There is an explanation on the Internet:

The window load event executes a bit later when the complete page was fully loaded, including all frames, objects and images. Therefore functions which concern images or other page contents should being placed in the Load event for the window or the C Ontent tag itself.

Look like Ha, the code is as follows:

        var height = document.body.clientHeight;        $ ("#doc2"). CSS ("height", height+ "px");        $ ("#doc2"). CSS ("Background-color", "E84C32");

Well, no matter what, there is this phenomenon ...

Just to judge the picture, I get the first slider, and then judge its onload

    var function () {        var height = document.body.clientHeight;        $ ("#doc2"). CSS ("height", height+ "px");        $ ("#doc2"). CSS ("Background-color", "E84C32");    }     var img = $ (' #firstimg ');     if (Img.prop (' complete ')) {        setposition ();     Else {        img.load(function() {setposition ();});    }

Roar, it's done, and then you have to study why Window.load failed ... There's no problem with the iphone ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.