易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : javascript

javascript 自定义对象的几种方式和注意点

对象初始化方式(也叫json对象创建方式)
<script type="text/javascript">
   var User = {
       name:"centerqi",
       age:25,
       toString:function()
       {
           alert(this.name+' is '+ this.age);
       }
   }
  
   function  display_user()
   {
/* 不能用这种方式去创建对象,因为json对象方式没有构造函数*/
 var centerqi = new User();
/* 直接用如下方式引用就可以了*/
  User .toString();
   }
  
   </script>
构造函数方式
 function User(name,age)
   {
       this.name =name;
       this.age = age;
       this.toString=function()
& ......

JavaScript删除数组中指定值的元素

/* 方法:Array.remove(dx)
* 功能:删除数组元素.
* 参数:dx删除元素的下标.
* 返回:在原数组上修改数组
*/
//经常用的是通过遍历,重构数组.
Array.prototype.remove=function(dx)
{
if(isNaN(dx)||dx>this.length){return false;}
for(var i=0,n=0;i<this.length;i++)
{
if(this[i]!=this[dx])
{
this[n++]=this[i]
}
}
this.length-=1
}

//在数组中获取指定值的元素索引
Array.prototype.getIndexByValue= function(value)
{
var index = -1;
for (var i = 0; i < this.length; i++)
{
if (this[i] == value)
{
index = i;
break;
}
}
return index;
}
//使用举例
a = ['1','2','3','4','5'];
var dx=a.getIndexByValue("2");
a.remove(dx); //删除下标为dx的元素 
  /*
  * 方法:Array.remove(dx)
  * 功能:删除数组元素.
  * 参数:dx删除元素的下标.
  * 返回:在原数组上修改数组
  */
  
 //经常用的是通过遍历,重构数组.
 Array.prototype.re ......

javascript 数据库取数据 全选和反选

    javascript所对应的全选和反选 。操作数据库记录。
以下是页面代码:
<tr>
<td colspan="6" width="100%">
<table border="2" width="100%">
<tr class="center">
<th width="20%" class="center">
全选/反选<input type="checkbox" name="all"
onclick="ckeckAll(this);">
</th>
<th width="20%" class="center">
箱主
</th>
<th width="20%" class="center">
箱号
</th>
<th width="20%" class="center">
箱型
</th>
<th width="20%" class="center">
箱类
</th>
</tr>
<tbody id="listTable">
<logic:iterate id="ylxhlist&qu ......

Javascript中的利用原形链和对象冒充创建类

看到一个曾经搞过web的人的blog中说到如果学Javascript不懂原形链,就太遗憾了,所以当自己看《javascript高级程序设计》时就留意了一下,说实话,下面的代码很简单,但是不是很懂所谓的原形链和对象冒充之类的东西 <!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>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type" />
<title>继承机制的实现--实例</title>
<script type="text/javascript">
   function Polygon(iSides){
    this.sides=iSides;
   }
   Polygon.prototype.getArea=function(){
    return 0;
   };
    function Triangle(iBase,iHeight){
    Polygon.call(this,3);
    this.b ......

javascript滚轮事件


<!doctype html>
<html lang="zh-ch">
<head>
<meta charset="utf-8" />
<meta content="IE=8" http-equiv="X-UA-Compatible"/>
<title>mousewheel的事件绑定 by 司徒正美</title>
<mce:script type="text/javascript"><!--
window.onload = function(){
var eventSupported = function( eventName,el ) {
el = el || document.createElement("div");
eventName = "on" + eventName;
var isSupported = (eventName in el);
if (el.setAttribute && !isSupported ) {
el.setAttribute(eventName, "return;");
isSupported = typeof el[eventName] === "function";
}
el = null;
return isSupported;
};
var addEvent = function(obj,type,callback){
if ( obj.addEventListener ) {
obj.addEventListener( type, callback, false );
} else if ( obj.attachEvent ) {
obj.attachEvent ......

javascript 经常用的一些特殊效果

1. 让文字不停的滚动。
     <marouee>滚动文字</marouee>
2.记录并显示网页的最后修改时间
     <script language="javascript">
         doucument.write("最后更新时间:" + document.lastModified + " ")
     </script>
3.添加到收藏夹
    <script language="javascript">
     function bookmarkit() {
         window.external.addFavorite('http://你的网址','你的网站名称');
      }
      if(document.all)
          document.write('<a href="#" onClick="bookmarkit()">加入收藏夹</a>');
     </script>
4.设置该页为首页
   <body bgcolor="#FFFFFF" text="#000000">
    <!--网址:http://你的网址-->
    <a ......
总记录数:2244; 总页数:374; 每页6 条; 首页 上一页 [57] [58] [59] [60] 61 [62] [63] [64] [65] [66]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号