<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <body> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var s = ""; s += "\r\n屏幕分辨率的宽:"+ window.screen.width; alert(s); } </script> </body> </html>