Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <!--
- To change this license header, choose License Headers in Project Properties.
- To change this template file, choose Tools | Templates
- and open the template in the editor.
- -->
- <html>
- <head>
- <title>TODO supply a title</title>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- </head>
- <body>
- <h1>Working with window object</h1>
- <input type="button" value="Open new window" id="button1" />
- <input type="button" value="Close new window" id="button2" />
- <input type="button" value="Scroll new window" id="button3" />
- <input type="button" value="Move new window" id="button4" />
- <input type="button" value="Resize new window" id="button5" /> <br />
- <script type="text/javascript">
- button1 = document.getElementById("button1");
- button2 = document.getElementById("button2");
- button3 = document.getElementById("button3");
- button4 = document.getElementById("button4");
- button5 = document.getElementById("button5");
- button1.onclick = openWin;
- button2.onclick = closeWin;
- button3.onclick = scrollWin;
- button4.onclick = moveWin;
- button5.onclick = resizeWin;
- function openWin() {
- myWin = window.open("","_blank","width=200,height=200,left=100,top=100,scrollbars=no", true);
- myWin.document.write("This is my new window <br /><br /><br /><br /><br /><br /><br /><br /> This is my new window <br />");
- myWin.document.write("This is my new window <br /><br /><br /><br /><br /><br /><br /><br /> This is my new window <br />");
- myWin.document.write("This is my new window <br /><br /><br /><br /><br /><br /><br /><br /> This is my new window <br />");
- }
- function closeWin() {
- myWin.close();
- }
- function scrollWin() {
- myWin.scrollBy(0,100);
- myWin.focus();
- }
- function moveWin() {
- myWin.moveBy(250,250);
- myWin.focus();
- }
- function resizeWin() {
- myWin.resizeBy(50,50);
- myWin.focus();
- }
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment