js

来源:互联网 发布:装企叁度erp软件 编辑:程序博客网 时间:2024/04/27 19:21
parseInt方法  eg:document.write(parseInt("34red"))若不能转化,返回NAN
paerseInt还可以实现进制转换: document.write(parseInt("AF",16));
同样 parseFloat("32.45")


str.slice()和str.substring()方法  str.substr()
str.slice(2,-3)  str.substring(起始位置,终止位置)  str.substr(起始位置,长度)


var amap=new Array("hello","wuyu","yuchua ")
alert(amap.toString());


split方法合并字符串:
var amap="hello,wuyu,yuchua ";
var fu=amap.split(",")
alert(fu.join("--"));


倒序输出:
var amap=["hello","wuyu","yuchua "];
alert(amap.reverse().toString());
排序:
amap.sort();


模拟栈的作用:
var stack = new Array();
stack.push("red");
stack.push("green");
stack.push("blue");
document.write(stack.toString()+"<br>");
var v=stack.pop();
document.write(v);


javascript的常用事件:
onblur 元素或窗口本身失去焦点时候触发
onfocus 任何元素或窗口本身获得焦点时候触发
onchange 改变<select>元素中的选项或在焦点后内容发生改变时触发
onclick
ondblclick 双击鼠标左键触发
onload
onreset
onsubmit
onselect
onscroll 
onmouseover
onmouseout
onmousemove
onmousedown


eg:strValue="hello" Yu strValue=new String("hello")等价的


常用对象:
1 String对象 
length  split(separator,limit) substr(start,length)  substring(from,to)
replace(searchValue,replaceValue)  charAt(index) toLowerCase()  toUpperCase()


2  Date对象
getFullYear()  getMonth() getDate() getDay() getHours()  getMinutes() getSeconds() 


3 window 对象 
常用属性:
frames location length history name status parent opener closed


常用方法:
alert() confirm() prompt() close() focus() open()  setTimeout(timer)
clearTimeout()  resizeBy(offsetx,offsety) print() 


在DOM中,HTML文档各个节点被视为各种类型的Node对象,可以通过Node对象的parentNode,firstChild,nextChild,lastChild,previousSibling等属性遍历文档树
Node对象的属性:
parentNode childNode firstChild  lastChild  previousSibling nextChild nodeName
nodeValue nodeType


 通过元素的ID获取文档中的指定元素:
document.getElementById("userId");
通过元素的name属性获取元素:

document.getElementByName("userName")[0];

window.open("以频道模式打开页面","_blank","channelmode")


<%@ page import="java.sql.*"%>
同一个页面可以有多个page指令 


page中的import: 用来导入包,下面几个包是默认自动导入的,不需要显式导入。默认导
入的包有:java.lang.*  javax.servlet.*  javax.servlet.jsp.*  
javax.servlet.http.* 


静态导入和动态导入的区别:静态导入是将被导入页面的
代码完全插入,两个页面生成一个整体的Servlet; 而动态导入则在Servlet中使用动态导入,从而将页面引入。


<input name="songType_more" type="hidden" id="songType_more" value="<%=request.getAttribute("typeID")==null?0:request.getAttribute("typeID")%>"/>

0 0