javascript部分对象
时间对象: Date()
使用前需要声明/创建对象, var currentTime = new Date();
常用方法:
getYear(); getMonth(); getDate(); getDay(); getHours(); getMinutes
(); getSeconds(); getTime();
setYear(); setMonth(); setDate(); setHours(); setMinutes();
setSeconds(); setTime();
getDay()返回的是星期几, getTime()返回的是从1970年到现在所经过的毫秒数
Window对象:
Window对象常用方法
alert()
open(URL,windowName,parameterList)
close()
promt(text, Defaulttext)
confirm(text)
setInterval(func, timer)
clearInterval(timer)
相关文档:
1. document.write( " "); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document- >html- >(head,body)
4.一个浏览器窗口中的DOM顺序是:window- >(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementB ......
/********************
* 取窗口滚动条高度
******************/
function getScrollTop()
{
var scrollTop=0;
if(document.documentElement&&document.documentElement.scrollTop)
{
......
<html>
<head>
<base href="<%=basePath%>">
<script type="text/javascript">
function check(){
var name1 = document.form1.name1.value;
var passwor ......
a href="#"> 点击链接后,页面会向上滚到页首,# 默认锚点为 #TOP
<a href="javascript:void(0)" onClick="window.open()"> 点击链接后,页面不动,只打开链接
<a href="#" onclick="javascript:return false;"> 作用同上,不同浏览器会有差异。
点击链接后,不想使页面滚到页首,就用href="javascript:v ......