Javascript 日记(1)

  没有整理,看到one-note中的一些记录,数量不多

Javascript 事件

  1. onloadonunload是在用户打开或者关闭页面时触发的
  2. onfocus
  3. onblur
  4. onchange
  5. onsubmit
  6. onmouseover onmouseout

例如

 

<href="http://www.google.com" onmouseout="alert('An onMouseOver event');return false"><img src="w3s.gif" alt="W3Schools" /></a>

  Show time example

 

代码
<html>

<head>

<script type="text/javascript">

function startTime()

{

var today=new Date();

var h=today.getHours();

var m=today.getMinutes();

var s=today.getSeconds();

// add a zero in front of numbers<10

m
=checkTime(m);

s
=checkTime(s);

document.getElementById(
'txt').innerHTML=h+":"+m+":"+s;

t
=setTimeout('startTime()',500);

}

 

function checkTime(i)

{

if (i<10)

 {

 i
="0" + i;

 }

return i;

}

</script>

</head>

 

<body onload="startTime()">

<div id="txt"></div>

</body>

</html>

Javascript 得到浏览器信息


 

代码
var x = navigator;

document.write("CodeName=" + x.appCodeName);

document.write("
<br />");

document.write("MinorVersion=" + x.appMinorVersion);

document.write("
<br />");

document.write("Name=" + x.appName);

document.write("
<br />");

document.write("Version=" + x.appVersion);

document.write("
<br />");

document.write("CookieEnabled=" + x.cookieEnabled);

document.write("
<br />");

document.write("CPUClass=" + x.cpuClass);

document.write("
<br />");

document.write("OnLine=" + x.onLine);

document.write("
<br />");

document.write("Platform=" + x.platform);

document.write("
<br />");

document.write("UA=" + x.userAgent);

document.write("
<br />");

document.write("BrowserLanguage=" + x.browserLanguage);

document.write("
<br />");

document.write("SystemLanguage=" + x.systemLanguage);

document.write("
<br />");

document.write("UserLanguage=" + x.userLanguage);


 

 

 

posted on 2010-02-05 21:36  vivy  阅读(188)  评论(2编辑  收藏  举报