易截截图软件、单文件、免安装、纯绿色、仅160KB

《JavaScript And DHTML Cookbook》学习笔记

  此文为读《JavaScript And DHTML Cookbook》后总结出来的笔记。由于当时是初学,所以笔记中难免有错误,欢迎指正。谢谢!
·字符串(String)
  1.声明
    var myString = new String("Every good boy does fine.");
    var myString = "Every good boy does fine.";
  2.字符串连接
    var myString = "Every " + "good boy " + "does fine.";
    var myString = "Every ";  myString += "good boy does fine.";
  3.截取字符串
    //截取第 6 位开始的字符
    var myString = "Every good boy does fine.";
    var section = myString.substring(6);    //结果: "good boy does fine."
   
    //截取第 0 位开始至第 10 位为止的字符
    var myString = "Every good boy does fine.";
    var section = myString.substring(0,10); //结果: "Every good"
   
    //截取从第 11 位到倒数第 6 位为止的字符
    var myString = "Every good boy does fine.";
    var section = myString.slice(11,-6);    //结果: "boy does"
   
    //从第 6 位开始截取长度为 4 的字符
    var myString = "Every good boy does fine.";
    var section = myString.substr(6,4);     //结果: "good"
  4.转换大小写
    var myString = "Hello";
    var lcString = myString.toLowerCase();  //结果: "hello"
    var ucString = myString.toUpperCase();  //结果: "HELLO"
  5.字符串比较
    var aString = "Hello!";
    var bString = new String("Hello!");
    if( aString == "Hello!" ){ }    //结果: true
    if( aString == bString ){ }     //结果: true
    if( aString === bString ){ }    //结果: fa


相关文档:

C#和JavaScript的简单互交

 
1.asp.net呼叫js
   
                     Response.Write("<script language=javascript>");
              ......

Javascript中最常用的55个经典技巧 收藏

Javascript中最常用的55个经典技巧 收藏
1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
2. <body onselectstart="return false"> 取消选取、防止复制
3. onpaste="return false" 不准粘贴
4 ......

JavaScript 复选框全选(二)

 
Code:
<!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>无标题页</title>
<mce:script language="javascript" type="te ......

JavaScript 复选框的反选

 
Code:
<!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>无标题页</title>
<mce:script language="javascript" type="te ......

JavaScript实现类的继承

在JavaScript中没有专门的机制来实现类的继承,但是可以通过拷贝一个类的prototype到另外一个类来实现继承,一种简单的实现如下:
function class1(){
}
function class2(){
}
class2.prototype=class1.prototype;
class2.prototype.moreProperty="xxx";
class2.prototype.moreMethod1=function(){
}
var obj = ne ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号