The purpose of this Code is to compare the image resolution and desktop resolution to determine whether the modified image is suitable for use as a visitor's desktop wallpaper. Through js, the screen resolution of the visitor's display is determined and a prompt is given.
First, the code example is provided:
Script <! -- Fw = "1920"; fh = "1200"; var uw = window. screen. width; var uh = window. screen. height; if (fw = uw) {if (fh = uh) {document. write ("perfect for your desktop")} else if (fh <uh) {document. write ("not suitable for your desktop")} else {document. write ("suitable for your desktop after cropping")} else if (fw <uw) {document. write ("slightly smaller size, not suitable for making your computer's tablecloth")} else if (fw> uw) {if (fw/fh = uw/uh) {document. write ("suitable for your desktop")} else {document. write ("not perfect for your resolution, you can cut it by yourself")} --> script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The purpose of this Code is to compare the image resolution and desktop resolution to determine whether the modified image is suitable for use as a guest's desktop wallpaper. The 1920 and 1200 parameters after fw = "1920" and fh = "1200" are respectively the width and height parameters of the image. They can be replaced by the actual image width and height parameters read by php. In the past, I used the if statements before 11th and 12 rows. After I increased the desktop resolution yesterday, I found two tips-if the desktop resolution is greater than the image resolution, after changing to else if parallel code, the error is solved.
In addition, I wanted to use the PHP method to transmit the image width and height. However, in this case, get should be used to deliver the image in advance, or there may be a jump or even an endless loop. So for the moment, I can only use JS to determine the image width and height. Of course, there are also methods of combining js and php, which are not very effective.