Tips on javascript attribute onresize_javascript

Source: Internet
Author: User
This article mainly introduces how to use the onresize attribute of javascript, which is very practical. We recommend it to you. If you need it, you can refer to it. On the javascript attribute onresize

// Obtain the screen width and dynamically assign the value var winWidth = 0; var winHeight = 0; function findDimensions () // function: Obtain the size {// obtain the window width if (window. innerWidth) winWidth = window. innerWidth; else if (document. body) & (document. body. clientWidth) winWidth = document. body. clientWidth; // obtain the window height if (window. innerHeight) winHeight = window. innerHeight; else if (document. body) & (document. body. clientHeight) winHeight = document. body. clientHeight; // detects the body in the Document to obtain the window size if (document.doc umentElement & document.doc umentElement. clientHeight & document.doc umentElement. clientWidth) {winHeight = document.doc umentElement. clientHeight; winWidth = document.doc umentElement. clientWidth;} // The result is output to two text boxes $ ("body "). height (winHeight) $ ("body "). width (winWidth)} findDimensions (); // call the function to obtain the value window. onresize = findDimensions; // -->

Only when I want to perform operations on the screen size can I remember that there is still an attribute for screen operations.

The onresize event occurs when the window or frame is adjusted.

The above is all the content of this article. I hope you will like it.

Related Article

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: 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.