1.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <title>标题页</title> 7 <SCRIPT language=javascript> 8 function onWindow(){ 9 myWindow=window.open('','','width=200,height=100'); 10 myWindow.document.write("This is 'myWindow'"); 11 } 12 function shake_xy(n) 13 { 14 if (myWindow.self.moveBy) 15 { 16 for (i = 10; i > 0; i--) 17 { 18 for (j = n; j > 0; j--) 19 { 20 myWindow.self.moveBy(0,i); 21 myWindow.self.moveBy(i,0); 22 myWindow.self.moveBy(0,-i); 23 myWindow.self.moveBy(-i,0); 24 } 25 } 26 } 27 } 28 29 function shake_x(n) 30 { 31 if (myWindow.self.moveBy) 32 { 33 for (i = 10; i > 0; i--) 34 { 35 for (j = n; j > 0; j--) 36 { 37 myWindow.self.moveBy(i,0); 38 myWindow.self.moveBy(-i,0); 39 } 40 } 41 } 42 } 43 44 function shake_y(n) 45 { 46 if (myWindow.self.moveBy) 47 { 48 for (i = 10; i > 0; i--) 49 { 50 for (j = n; j > 0; j--) 51 { 52 myWindow.self.moveBy(0,i); 53 myWindow.self.moveBy(0,-i); 54 } 55 } 56 } 57 } 58 </SCRIPT> 59 </head> 60 <BODY>请启动浏览器观看效果<BR> 61 <!--将以下代码加入HTML的<Body></Body>之间--> 62 <input type="button" value="111" onclick="onWindow()"> 63 <A href="#" onclick="shake_x(5)">左右震动</A> 64 <A href="#" onclick="shake_y(5)">上下震动</A> 65 <A href="#" onclick="shake_xy(2)">整屏震动</A> 66 </body></html>