按指定像素调整窗口大小

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. var w;
  6. function openwindow() {
  7. w = window.open('','', 'width=100,height=100');
  8. w.focus();
  9. }
  10.  
  11. function myFunction() {
  12. w.resizeBy(50, 50);
  13. w.focus();
  14. }
  15.  
  16. </script>
  17. </head>
  18. <body>
  19.  
  20. <button onclick="openwindow()">创建一个窗口</button>
  21. <button onclick="myFunction()">调整窗口大小</button>
  22.  
  23. </body>
  24. </html>