javascript笔记
定义变量
var test=10;
使用对象属性
可以使用 . 操作符获得属性,也可以使用数组下标获得,比如
for(var prop in document)
document.write(document[prop]+"<br>");
With 声明对象,之后再用到对象就不必声明了
with(document){
write("Hello World<br>标题: ");
write(title);
}
常用对象
字符串对象
big 大字体显示
italics 斜体显示
bold 粗体显示
small 小字体显示
blink 闪烁显示
fixed 打字机字体显示
fontsize(size) 控制字体大小
算术函数math对象
时间日期对象
function showTime()
{
var now=new Date();
with(document.clock.txt){
with(now){
value=(getYear()+"年"+(1+getMonth())+"月"+getDate()+"日");
value+=(" "+getHours()+":"+getMinutes()+":"+getSeconds());
}
}
setTimeout("showTime()",1000);
}
<head>
<script language="javascript" type="text/javascript" src="js.js"></script>
</head>
<body onload="showTime()">
<form name="clock" action="">
<input type="text" name="txt" value=""/></form>
</body>
</html>
相关文档:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript真正的鼠标放上动画加载大图的代码</title>
<style>
*{ padding:0; margin ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DOM</title>
<meta http-equiv="Content-Type&quo ......
click()对象.click()使对象被点击。
closed对象.closed对象窗口是否已关闭true/false
clearTimeout(对象)清除已设置的setTimeout对象
clearInterval(对象)清除已设置的setInterval对象
confirm("提示信息")弹出确认框,确定返回true取消返回false
cursor:样式更改鼠标样式handcrosshairtextwaithelpdefaultautoe/s/w/n ......
1.首先下载SyntaxHighlighter.
2.解压到SyntaxHighlighter目录中.
3.建立HTML文件:
<pre name="code" class="Ruby">
...Ruby代码...
</pre>
可以应用在pre和textarea两种HTML标签内,name为code,class为要着色的语言,现在支持C, C#, CSS, Delphi, Java, JScript, Php, Pyth ......