面向对象的JavaScript的表格排序问题
JavaScript表格排序有很多种方式,不过在使用面向对象的方式进行JavaScript排序时IE会有一些问题。代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>演示表格的排序功能</title>
</head>
<script type="text/javascript">
var previousColumnIndex = 0;
ArrayUtil = {
arrayOne: [3, 32, 2, 5],
arrayTwo: ["3","32","2","5"],
demoNoarmal: function(){
this.arrayOne.sort();//默认方式排序
alert(this.arrayOne);
},
comparionAsc: function(one, two){ //升序
if(one < two){
return -1;
}else if(one > two){
return 1;
}else{
return 0;
}
},
comparionDesc: function(one, two){ //降升
if(one < two){
return 1;
}else if(one > two){
return -1;
}else{
return 0;
}
},
comparionSort: function(){
//this.arrayOne.sort(this.comparionAsc);
this.arrayOne.sort(this.comparionDesc);
alert(this.arrayOne);
},
comparionAscForString: function(one, two){
//return one.localeCompare(two); //升序
return -one.localeCompare(two); //降序
},
comparionString: function(){
this.arrayTwo.sort(this.comparionAscForString);
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
// <!CDATA[
//define
var xmlhttp;
var value=new Array();
var variable=new Array();
//Show Response MSG.
function handleStateChange()
{
var h=document.getElementById("Label1");
if(xmlhttp.readyState==4)
{
if(xmlhttp.status==200)
{
alert(xmlhttp. ......
下面都是个人理解以及查找的网上的资料,如有不对的地方请指正
prototype
prototype在这里是原型的意思,不是指那个框架...
每个函数就是一个对象(Function),当函数被解析后会添加一个prototype的对象,然后prototype会添加一个constructor的属性
它指向那个函数的
比如定义一个function test(){}
它会 ......
JavaScript Table排序
序二(09/05/03)
近来还是那么忙,趁五一更新一下程序吧。
这个版本主要增加和改进了以下东西:
1,对字符串改用localeCompare来比较;
2,一次排序中能使用多个排序对象(用于值相等时再排序);
3,修正一些发现的问题;
4,改进程序结构,个人觉得是更灵活更方便了;
5,增加bool类型比 ......
匿名函数
函数是JavaScript中最灵活的一种对象,这里只是讲解其匿名函数的用途。匿名函数:就是没有函数名的函数。
1、函数的定义,首先简单介绍一下函数的定义,大致可分为三种方式
第一种:这也是最常规的一种
function double( x ){
return 2 * x;
}
第二种:这种方法使用了Func ......