1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN"> 3 <head> 4 <title>Setting File Title</title> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 <meta http-equiv="Content-Language" content="zh-CN" /> 7 <meta name="author" content="skydao" /> 8 <meta name="Copyright" content="skydao" /> 9 <meta name="description" content="描述内容" /> 10 <meta http-equiv="refresh" content="10;url=http://yourlink" /> 11 <meta name="keywords" content="php mysql html css javascript ajax java java ee"/> 12 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 13 <meta name="viewport" content="width=device-width" /> 14 <link rel="stylesheet" href="#" type="text/css" media="handheld, all" /> 15 <style type="text/css" media="print, screen"> 16 17 </style> 18 <link rel="stylesheet" href="/2008/site/css/print" type="text/css" media="print" /> 19 <link rel="shortcut icon" href="#.ico" type="image/x-icon" /> 20 <script type="text/javascript" src="#"></script> 21 <script type="text/javascript"> 22 //<![CDATA[ 23 // javascript code 24 //]]> 25 window.onload=function(){ 26 27 //var userName="xiaoming"; 28 29 //alert(userName); 30 var a = { 31 init: function () {alert("start");}, 32 exit: function () {alert("exit");} 33 } 34 35 a.init(); 36 a.exit(); 37 } 38 39 </script> 40 </head> 41 <body> 42 </body> 43 </html>
在window.onload中,格式是json的格式,不清楚这样使用的好处,但是看着挺简洁的。
运行结果,先弹出start,再弹出exit