IT-Academy

JS Okná

Jan 5th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.14 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8.     <head>
  9.         <title>TODO supply a title</title>
  10.         <meta charset="UTF-8">
  11.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12.     </head>
  13.     <body>
  14.         <h1>Working with window object</h1>
  15.    
  16.     <input type="button" value="Open new window" id="button1" />
  17.     <input type="button" value="Close new window" id="button2" />
  18.     <input type="button" value="Scroll new window" id="button3" />
  19.     <input type="button" value="Move new window" id="button4" />
  20.     <input type="button" value="Resize new window" id="button5" /> <br />
  21.        
  22.     <script type="text/javascript">
  23.         button1 = document.getElementById("button1");
  24.         button2 = document.getElementById("button2");
  25.         button3 = document.getElementById("button3");
  26.         button4 = document.getElementById("button4");
  27.         button5 = document.getElementById("button5");
  28.        
  29.         button1.onclick = openWin;
  30.         button2.onclick = closeWin;
  31.         button3.onclick = scrollWin;
  32.         button4.onclick = moveWin;
  33.         button5.onclick = resizeWin;
  34.                
  35.                
  36.        
  37.         function openWin() {
  38.             myWin = window.open("","_blank","width=200,height=200,left=100,top=100,scrollbars=no", true);
  39.             myWin.document.write("This is my new window <br /><br /><br /><br /><br /><br /><br /><br /> This is my new window <br />");
  40.             myWin.document.write("This is my new window <br /><br /><br /><br /><br /><br /><br /><br /> This is my new window <br />");
  41.             myWin.document.write("This is my new window <br /><br /><br /><br /><br /><br /><br /><br /> This is my new window <br />");
  42.         }
  43.        
  44.         function closeWin() {
  45.             myWin.close();
  46.         }
  47.                
  48.                
  49.        
  50.         function scrollWin() {
  51.             myWin.scrollBy(0,100);
  52.             myWin.focus();
  53.         }
  54.                
  55.                
  56.        
  57.         function moveWin() {
  58.             myWin.moveBy(250,250);
  59.             myWin.focus();
  60.         }
  61.        
  62.         function resizeWin() {
  63.             myWin.resizeBy(50,50);
  64.             myWin.focus();
  65.         }
  66.                
  67.     </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment