1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> body{ width: 4000px; height: 3000px; padding-top: 500px; } </style> </head> <body> <input type="button" value="打开网页" id="open"/> <input type="button" value="关闭网页" id="close"/> <input type="button" value="moveTo" id="to"/> <input type="button" value="moveBy" id="by"/> <input type="button" value="resizeTo" id="sizeTo"/> <input type="button" value="resizeBy" id="sizeBy"/> <input type="button" value="scrollTo" id="sto"/> <input type="button" value="scrollBy" id="sby"/> </body> </html> <script type="text/javascript">
var openEl = document.querySelector("#open"); var closeEl = document.querySelector("#close"); var newWindow = []; openEl.onclick = function(){ console.log("0000");
for(var i = 0; i < 5; i++){ newWindow[i] = window.open("", i+"", "width=400, height=400, left=100, top=100"); } } closeEl.onclick = function(){
for(var i = 0; i < newWindow.length; i++){ newWindow[i].close(); } }
to.onclick = function(){ newWindow[4].document.body.style.backgroundColor = "red"; newWindow[4].moveTo(100, 200); } by.onclick = function(){ newWindow[3].document.body.style.backgroundColor = "green"; newWindow[3].moveBy(-100, 200); }
sizeTo.onclick = function(){ newWindow[4].resizeTo(200, 300); } sizeBy.onclick = function(){ newWindow[4].resizeBy(-200, -100); }
sto.onclick = function(){ window.scrollTo(400, 300); } sby.onclick = function(){ window.scrollBy(0, 150); } </script>
|