Solve jquery dynamic get phone screen high and wide problem _jquery

Source: Internet
Author: User
Today, I helped my colleagues solve the problem of using jquery to get a dynamic mobile screen wide.

The problem is that when a co-worker uses a picture control that needs a full screen scrolling, you need to get the height of the screen to set the picture to full screen. But he used $ (window). Height () never get high for the first time, after refreshing, I tried using window.onload=function () {} to solve the problem and found that it still failed.

Finally, I think it must be because the second refresh, the browser has a cache, so you can get high, then the page load Dom is certainly the time difference, resulting in this problem, so the use of settimeout (method name, 500), a delay of 500 milliseconds, the result is normal.

So when your friends can't get a wide screen, try this.

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.