javascript
//加载顺序 //针对js的顺序 1,head引入。2,body体页面js。3,html结尾引入。4,baod标签函数 //js6种类型1,number。2,string。3,boolean。4,object。5,undefined.6,function。类型判断用typeof //number包括int,float,double. 计算用parentInt,parentdouble,parentfloat转型 //string可以用+号拼接,转成number就是计算 //object包括数组 //在js里面 null,0,“”,‘’等没有值的变量为假,有值为真 //经测试,在if判断里面 a=4 || b=4 不成立 // ||具有短路功能 //arguments 参数数组,function test(){} //test(1,2,3,4,5,6,7,8,9) //global对象! 1,escape,编码;2,unescape,解码。3,parseFloat,4,parseInt.5,isNaN.是否为保留字。6,eval。编译器。
//dom //document 文档,html,xml (标记语言) //object 对象 //model //获取元素 // 标记名(多个) id(唯一) name(多个) // document中的三个方法 // var obj = document.getElementsByTagName("div"); // var obj = document.getElementById("one"); // var obj = document.getElementByName("two"); // 操作内容 // ie用innerText FF用textContent 操作的是内容,不渲染页面 // innerHTML 针对当前元素内的所有内容,包括标签 // 判断IE和FF 判断document.all true是IE false是FF // className 可以把CSS名称样式当成对象操作 //<input type="checkbox" name="name" onclick=test(this) /> this代表当前整个元素 // 7种对象获取方式 // document.forms[1].username.value // document.forms["frm2"].username.value // document.forms.item(1).username.value // document.forms.item("frm2").username.value // document.forms.frm2.username.value // document.frm2.username.value // document["frm2"].username.value //获取节点 // 父节点 parentNode // 子节点 childNodes, firsNode, lastNode // 同胞节点 nextSibling, parviousSibling // 节点类型 nodeType //返回节点类型 // 元素 1. // 属性 2. // 文本 3. // 注释 4. // 文档 5. // 节点名称 nodeName // 节点值 nodeValue // createElement("") 创建节点 // addendChild(); 添加子节点 // insertBefort(); 插入在什么之前 // removeChild(); 删除子节点
//事件 // 事件源 任何一个html元素 // 事件 操作 鼠标和键盘事件 // 事件处理程序 // load加载 // unload关闭 // beforeunload关闭之前 // focus 焦点 // blur 失去焦点 // submit 提交事件 // change 改变 // 事件添加的三种方法 //1: <tag on事件 = “事件处理程序” /> //2 : <script>对象.on事件=事件处理程序</script> //3 : <script for="事件源id" event=“事件”>事件处理程序</srcipt>
// <body oncontextmenu="return false;"></body> 阻止右键 页面加载完之后才加载这个函数 // <body onunload="alert('goodbye')" onbeforeunload="event.returnValue='确认关闭'"
// 经测试,没什么用,只有ie的F5刷新有用,点x号没用, 火狐根本没反应
// bom 浏览器对象
// 内置属性
// status
// opener 父窗体 子窗体
// closed
// 内置对象
// 动态效果四个方法
// setInterval()
// setInterval(函数, 时间); 1000是一秒
// clearInterval();
// setTimrout();
// setTimeout(函数, 时间); 1000是一秒
// clearTimeout();
// window.location.href=url; 在本页面打开
// window.open("url","窗体名称","位置和外观"); 返回数据之后可以互相操作
// 一个小算法
var num-0;
var dir=1;
setInterval(function(){
if(num > 40 || num < 0){
dir = -1*dir;
}
num+=dir;
var space = "";
for(var = 0; i<num; i++){
space += " ";
}
window.status=space + "www.baidu.com";
},100);
// frame 分针
// open opener 可以操作父窗体
// location 位置跳转
// <meta http-equiv="refresh" content="3:url=http//www.baidu.com"> refresh 刷新 content="3:http//www.baidu.com" 3秒后跳转到百度页面 在head里面用的跳转
// header("location:login.html")
// window.navigate('url')
// location.href="url"
// location.replace('url') 跳转后不能后退
// location="url"
// location.reload(true)
// history 历史对象
// history.back() 返回
// hisroty.go(-1) 返回上一步
// hisroty.go(-2) 返回上二步
// screen 屏幕对象
// screen.availHeight 屏幕高度
// screen.availWidth 屏幕宽度
// screen.height 屏幕本身高度
// screen.width 屏幕本身宽度
// screen.colorDepth 屏幕色盘
// window.cliphoardData.setData("Text",content) 文本复制 content是内容对象
// 表单事件
// focus(); 获取焦点
// blur(); 失去焦点
// change(); 改变
// 在from上用onsubmit=“”;