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

javascript实现key value对象

JavaScript的实现的Map,用着挺方便的,不知道性能怎么样。
自己用只有不超过10个元素,所以性能无所谓了。
/********************jsmap.js**************************/
/////// map 类
function classMap() {
  this.map = new Array();
 
  var struct = function(key,
value){
      this.key = key;
   this.value = value;
 };
 
 
this.lookUp = function (key){
   for (var i = 0; i <
this.map.length; i++)
   {
  if ( this.map[i].key === key )
  {
   
return this.map[i].value;
  }
   }  
   return null;
 };
 

  this.setAt = function (key, value){ 
      for (var i = 0; i
< this.map.length; i++)
   {
  if ( this.map[i].key === key )
  {
   
this.map[i].value = value;
    return;
  }
   }  
  
this.map[this.map.length] = new struct(key,value); 
 };
 
 
this.removeKey = function removeKey(key){
   var v;
   for (var i =
0; i < this.map.length; i++)
   {
  v = this.map.pop();
  if
( v.key === key )
    continue;
   
  this.map.unshift(v);
  
}
 };
 
  this.getCount = function(){
   return
this.map.length;
 };
 
  this.isEmpty = function(){
  
return this.map.length <= 0;
 };
}
////////////////////////////////////////////////////////////////////////////////////////////////
/********************调用***********************/
window.onload = function(){
  var map = new classMap();
  alert("is the map empty? " +
map.isEmpty());
  // string to array
  map.setAt("sw1", "aaaa


相关文档:

介绍怎样解决JavaScript页面刷新与弹出窗口的问题。

 介绍怎样解决JavaScript页面刷新与弹出窗口的问题。
  1.无提示刷新网页
  大家有没有发现,有些网页,刷新的时候,会弹出一个提示窗口,点“确定”才会刷新。
  而有的页面不会提示,不弹出提示窗口,直接就刷新了.
  如果页面没有form,则不会弹出提示窗口。如果页面有form表单,
  a)< fo ......

javascript无缝滚动源码

Marquee图片无缝滚动关键词: Marquee                                          
先了解一下 ......

javascript图片缩放


<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体" ......

进一步理解javascript对象、数组和哈希表


进一步理解javascript对象、数组和哈希表 



在javascript中,对象实际上就是一个哈希表,比如下面这个user对象:
function user(n, a)
{
this.name = n;
this.age = a;
this.toString = function() {
return 'Name:' + ......

[转]asp的textbox的javascript应用

<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"> </script>
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
<title ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号