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.