JavaScript代码收集

来源:互联网 发布:2016部门决算软件 编辑:程序博客网 时间:2024/06/06 02:01


 JavaScript代码收集


--来自网上收集


substring 方法
返回位于 String 对象中指定位置的子字符串。

strVariable.substring(start, end)
"String Literal".substring(start, end)

参数
start

指明子字符串的起始位置,该索引从 0 开始起算。

end

指明子字符串的结束位置,该索引从 0 开始起算。

说明
substring 方法将返回一个包含从 start 到最后(不包含 end )的子字符串的字符串。

substring 方法使用 start 和 end 两者中的较小值作为子字符串的起始点。例如, strvar.substring(0, 3) 和 strvar.substring(3, 0) 将返回相同的子字符串。

如果 start 或 end 为 NaN 或者负数,那么将其替换为0。

子字符串的长度等于 start 和 end 之差的绝对值。例如,在 strvar.substring(0, 3) 和 strvar.substring(3, 0) 返回的子字符串的的长度是 3。

示例
下面的示例演示了 substring 方法的用法。

function SubstringDemo(){
   var ss;                         // 声明变量。
   var s = "The rain in Spain falls mainly in the plain..";
   ss = s.substring(12, 17);   // 取子字符串。
   return(ss);                     // 返回子字符串。
}
=====================================================


substr 方法
返回一个从指定位置开始的指定长度的子字符串。

stringvar.substr(start [, length ])

参数
stringvar

必选项。要提取子字符串的字符串文字或 String 对象。

start

必选项。所需的子字符串的起始位置。字符串中的第一个字符的索引为 0。

length

可选项。在返回的子字符串中应包括的字符个数。

说明
如果 length 为 0 或负数,将返回一个空字符串。如果没有指定该参数,则子字符串将延续到 stringvar 的最后。

示例
下面的示例演示了substr 方法的用法。

function SubstrDemo(){
   var s, ss;                // 声明变量。
   var s = "The rain in Spain falls mainly in the plain.";
   ss = s.substr(12, 5);  // 获取子字符串。
   return(ss);               // 返回 "Spain"。
}


 JavaScript 是使用“对象化编程”的,或者叫“面向对象编程”的。所谓“对象化编程”,意思是把 JavaScript 能涉及的范围划分成大大小小的对象,对象下面还继续划分对象直至非常详细为止,所有的编程都以对象为出发点,基于对象。小到一个变量,大到网页文档、窗口甚至屏幕,都是对象。这一章将“面向对象”讲述 JavaScript 的运行情况。

对象的基本知识
对象是可以从 JavaScript“势力范围”中划分出来的一小块,可以是一段文字、一幅图片、一个表单(Form)等等。每个对象有它自己的属性、方法和事件。对象的属性是反映该对象某些特定的性质的,例如:字符串的长度、图像的长宽、文字框(Textbox)里的文字等等;对象的方法能对该对象做一些事情,例如,表单的“提交”(Submit),窗口的“滚动”(Scrolling)等等;而对象的事件就能响应发生在对象上的事情,例如提交表单产生表单的“提交事件”,点击连接产生的“点击事件”。不是所有的对象都有以上三个性质,有些没有事件,有些只有属性。引用对象的任一“性质”用“<对象名>. <性质名>”这种方法。

基本对象
现在我们要复习以上学过的内容了——把一些数据类型用对象的角度重新学习一下。

Number “数字”对象。这个对象用得很少,作者就一次也没有见过。不过属于“Number”的对象,也就是“变量”就多了。

属性

MAX_VALUE 用法:Number.MAX_VALUE;返回“最大值”。
MIN_VALUE 用法:Number.MIN_VALUE;返回“最小值”。
NaN 用法:Number.NaN 或 NaN;返回“NaN”。“NaN”(不是数值)在很早就介绍过了。
NEGATIVE_INFINITY 用法:Number.NEGATIVE_INFINITY;返回:负无穷大,比“最小值”还小的值。
POSITIVE_INFINITY 用法:Number.POSITIVE_INFINITY;返回:正无穷大,比“最大值”还大的值。

方法

toString() 用法:<数值变量>.toString();返回:字符串形式的数值。如:若 a == 123;则 a.toString() == '123'。

String 字符串对象。声明一个字符串对象最简单、快捷、有效、常用的方法就是直接赋值。

属性

length 用法:<字符串对象>.length;返回该字符串的长度。

方法

charAt() 用法:<字符串对象>.charAt(<位置>);返回该字符串位于第<位置>位的单个字符。注意:字符串中的一个字符是第 0 位的,第二个才是第 1 位的,最后一个字符是第 length - 1 位的。
charCodeAt() 用法:<字符串对象>.charCodeAt(<位置>);返回该字符串位于第<位置>位的单个字符的 ASCII 码。
fromCharCode() 用法:String.fromCharCode(a, b, c...);返回一个字符串,该字符串每个字符的 ASCII 码由 a, b, c... 等来确定。
indexOf() 用法:<字符串对象>.indexOf(<另一个字符串对象>[, <起始位置>]);该方法从<字符串对象>中查找<另一个字符串对象>(如果给出<起始位置>就忽略之前的位置),如果找到了,就返回它的位置,没有找到就返回“-1”。所有的“位置”都是从零开始的。
lastIndexOf() 用法:<字符串对象>.lastIndexOf(<另一个字符串对象>[, <起始位置>]);跟 indexOf() 相似,不过是从后边开始找。
split() 用法:<字符串对象>.split(<分隔符字符>);返回一个数组,该数组是从<字符串对象>中分离开来的, <分隔符字符>决定了分离的地方,它本身不会包含在所返回的数组中。例如:'1&2&345&678'.split ('&')返回数组:1,2,345,678。关于数组,我们等一下就讨论。
substring() 用法:<字符串对象>.substring(<始>[, <终>]);返回原字符串的子字符串,该字符串是原字符串从<始>位置到<终>位置的前一位置的一段。<终 > - <始> = 返回字符串的长度(length)。如果没有指定<终>或指定得超过字符串长度,则子字符串从<始>位置一直取到原字符串尾。如果所指定的位置不能返回字符串,则返回空字符串。
substr() 用法:<字符串对象>.substr(<始>[, <长>]);返回原字符串的子字符串,该字符串是原字符串从<始>位置开始,长度为<长>的一段。如果没有指定 <长>或指定得超过字符串长度,则子字符串从<始>位置一直取到原字符串尾。如果所指定的位置不能返回字符串,则返回空字符串。
toLowerCase() 用法:<字符串对象>.toLowerCase();返回把原字符串所有大写字母都变成小写的字符串。
toUpperCase() 用法:<字符串对象>.toUpperCase();返回把原字符串所有小写字母都变成大写的字符串。

Array 数组对象。数组对象是一个对象的集合,里边的对象可以是不同类型的。数组的每一个成员对象都有一个“下标”,用来表示它在数组中的位置(既然是“位置”,就也是从零开始的啦)。

数组的定义方法:

var <数组名> = new Array();

这样就定义了一个空数组。以后要添加数组元素,就用:

<数组名>[<下标>] = ...;

注意这里的方括号不是“可以省略”的意思,数组的下标表示方法就是用方括号括起来。

如果想在定义数组的时候直接初始化数据,请用:

var <数组名> = new Array(<元素1>, <元素2>, <元素3>...);

例如,var myArray = new Array(1, 4.5, 'Hi'); 定义了一个数组 myArray,里边的元素是:myArray[0] == 1; myArray[1] == 4.5; myArray[2] == 'Hi'。

但是,如果元素列表中只有一个元素,而这个元素又是一个正整数的话,这将定义一个包含<正整数>个空元素的数组。

注意:JavaScript只有一维数组!千万不要用“Array(3,4)”这种愚蠢的方法来定义 4 x 5 的二维数组,或者用“myArray[2,3]”这种方法来返回“二维数组”中的元素。任意“myArray[...,3]”这种形式的调用其实只返回了 “myArray[3]”。要使用多维数组,请用这种虚拟法:

var myArray = new Array(new Array(), new Array(), new Array(), ...);

其实这是一个一维数组,里边的每一个元素又是一个数组。调用这个“二维数组”的元素时:myArray[2][3] = ...;

属性

length 用法:<数组对象>.length;返回:数组的长度,即数组里有多少个元素。它等于数组里最后一个元素的下标加一。所以,想添加一个元素,只需要:myArray[myArray.length] = ...。

方法

join() 用法:<数组对象>.join(<分隔符>);返回一个字符串,该字符串把数组中的各个元素串起来,用<分隔符>置于元素与元素之间。这个方法不影响数组原本的内容。
reverse() 用法:<数组对象>.reverse();使数组中的元素顺序反过来。如果对数组[1, 2, 3]使用这个方法,它将使数组变成:[3, 2, 1]。
slice() 用法:<数组对象>.slice(<始>[, <终>]);返回一个数组,该数组是原数组的子集,始于<始>,终于<终>。如果不给出<终>,则子集一直取到原数组的结尾。
sort() 用法:<数组对象>.sort([<方法函数>]);使数组中的元素按照一定的顺序排列。如果不指定<方法函数>,则按字母顺序排列。在这种情况下,80 是比 9 排得前的。如果指定<方法函数>,则按<方法函数>所指定的排序方法排序。<方法函数>比较难讲述,这里只将一些有用的<方法函数>介绍给大家。

按升序排列数字:

function sortMethod(a, b) {
    return a - b;
}

myArray.sort(sortMethod);

按降序排列数字:把上面的“a - b”该成“b - a”。

有关函数,请看下面。

Math “数学”对象,提供对数据的数学计算。下面所提到的属性和方法,不再详细说明“用法”,大家在使用的时候记住用“Math.<名>”这种格式。

属性

E 返回常数 e (2.718281828...)。
LN2 返回 2 的自然对数 (ln 2)。
LN10 返回 10 的自然对数 (ln 10)。
LOG2E 返回以 2 为低的 e 的对数 (log2e)。
LOG10E 返回以 10 为低的 e 的对数 (log10e)。
PI 返回π(3.1415926535...)。
SQRT1_2 返回 1/2 的平方根。
SQRT2 返回 2 的平方根。

方法

abs(x) 返回 x 的绝对值。
acos(x) 返回 x 的反余弦值(余弦值等于 x 的角度),用弧度表示。
asin(x) 返回 x 的反正弦值。
atan(x) 返回 x 的反正切值。
atan2(x, y) 返回复平面内点(x, y)对应的复数的幅角,用弧度表示,其值在 -π 到 π 之间。
ceil(x) 返回大于等于 x 的最小整数。
cos(x) 返回 x 的余弦。
exp(x) 返回 e 的 x 次幂 (ex)。
floor(x) 返回小于等于 x 的最大整数。
log(x) 返回 x 的自然对数 (ln x)。
max(a, b) 返回 a, b 中较大的数。
min(a, b) 返回 a, b 中较小的数。
pow(n, m) 返回 n 的 m 次幂 (nm)。
random() 返回大于 0 小于 1 的一个随机数。
round(x) 返回 x 四舍五入后的值。
sin(x) 返回 x 的正弦。
sqrt(x) 返回 x 的平方根。
tan(x) 返回 x 的正切。

Date 日期对象。这个对象可以储存任意一个日期,从 0001 年到 9999 年,并且可以精确到毫秒数(1/1000 秒)。在内部,日期对象是一个整数,它是从 1970 年 1 月 1 日零时正开始计算到日期对象所指的日期的毫秒数。如果所指日期比 1970 年早,则它是一个负数。所有日期时间,如果不指定时区,都采用“UTC”(世界时)时区,它与“GMT”(格林威治时间)在数值上是一样的。

定义一个日期对象:

var d = new Date;

这个方法使 d 成为日期对象,并且已有初始值:当前时间。如果要自定初始值,可以用:

var d = new Date(99, 10, 1);     //99 年 10 月 1 日
var d = new Date('Oct 1, 1999'); //99 年 10 月 1 日

等等方法。最好的方法就是用下面介绍的“方法”来严格的定义时间。

方法

以下有很多“g/set[UTC]XXX”这样的方法,它表示既有“getXXX”方法,又有“setXXX”方法。“get”是获得某个数值,而 “set”是设定某个数值。如果带有“UTC”字母,则表示获得/设定的数值是基于 UTC 时间的,没有则表示基于本地时间或浏览期默认时间的。

如无说明,方法的使用格式为:“<对象>.<方法>”,下同。

g/set[UTC]FullYear() 返回/设置年份,用四位数表示。如果使用“x.set[UTC]FullYear(99)”,则年份被设定为 0099 年。
g/set[UTC]Year() 返回/设置年份,用两位数表示。设定的时候浏览器自动加上“19”开头,故使用“x.set[UTC]Year(00)”把年份设定为 1900 年。
g/set[UTC]Month() 返回/设置月份。
g/set[UTC]Date() 返回/设置日期。
g/set[UTC]Day() 返回/设置星期,0 表示星期天。
g/set[UTC]Hours() 返回/设置小时数,24小时制。
g/set[UTC]Minutes() 返回/设置分钟数。
g/set[UTC]Seconds() 返回/设置秒钟数。
g/set[UTC]Milliseconds() 返回/设置毫秒数。
g/setTime() 返回/设置时间,该时间就是日期对象的内部处理方法:从 1970 年 1 月 1 日零时正开始计算到日期对象所指的日期的毫秒数。如果要使某日期对象所指的时间推迟 1 小时,就用:“x.setTime(x.getTime() + 60 * 60 * 1000);”(一小时 60 分,一分 60 秒,一秒 1000 毫秒)。
getTimezoneOffset() 返回日期对象采用的时区与格林威治时间所差的分钟数。在格林威治东方的市区,该值为负,例如:中国时区(GMT+0800)返回“-480”。
toString() 返回一个字符串,描述日期对象所指的日期。这个字符串的格式类似于:“Fri Jul 21 15:43:46 UTC+0800 2000”。
toLocaleString() 返回一个字符串,描述日期对象所指的日期,用本地时间表示格式。如:“2000-07-21 15:43:46”。
toGMTString() 返回一个字符串,描述日期对象所指的日期,用 GMT 格式。
toUTCString() 返回一个字符串,描述日期对象所指的日期,用 UTC 格式。
parse() 用法:Date.parse(<日期对象>);返回该日期对象的内部表达方式。

全局对象
全局对象从不现形,它可以说是虚拟出来的,目的在于把全局函数“对象化”。在 Microsoft JScript 语言参考中,它叫做“Global 对象”,但是引用它的方法和属性从来不用“Global.xxx”(况且这样做会出错),而直接用“xxx”。

属性

NaN 一早就说过了。

方法

eval() 把括号内的字符串当作标准语句或表达式来运行。
isFinite() 如果括号内的数字是“有限”的(介于 Number.MIN_VALUE 和 Number.MAX_VALUE 之间)就返回 true;否则返回 false。
isNaN() 如果括号内的值是“NaN”则返回 true 否则返回 false。
parseInt() 返回把括号内的内容转换成整数之后的值。如果括号内是字符串,则字符串开头的数字部分被转换成整数,如果以字母开头,则返回“NaN”。
parseFloat() 返回把括号内的字符串转换成浮点数之后的值,字符串开头的数字部分被转换成浮点数,如果以字母开头,则返回“NaN”。
toString() 用法:<对象>.toString();把对象转换成字符串。如果在括号中指定一个数值,则转换过程中所有数值转换成特定进制。
escape() 返回括号中的字符串经过编码后的新字符串。该编码应用于 URL,也就是把空格写成“%20”这种格式。“+”不被编码,如果要“+”也被编码,请用:escape('...', 1)。
unescape() 是 escape() 的反过程。解编括号中字符串成为一般字符串。

函数
函数的定义

所谓“函数”,是有返回值的对象或对象的方法。

函数的种类

常见的函数有:构造函数,如 Array(),能构造一个数组;全局函数,即全局对象里的方法;自定义函数;等等。

自定义函数

定义函数用以下语句:

function 函数名([参数集]) {
    ...
    [return[ <值>];]
    ...
}

其中,用在 function 之后和函数结尾的大括号是不能省去的,就算整个函数只有一句。

函数名与变量名有一样的起名规定,也就是只包含字母数字下划线、字母排头、不能与保留字重复等。

参数集可有可无,但括号就一定要有。

参数 是函数外部向函数内部传递信息的桥梁,例如,想叫一个函数返回 3 的立方,你就要让函数知道“3”这个数值,这时候就要有一个变量来接收数值,这种变量叫做参数。

参数集是一个或多个用逗号分隔开来的参数的集合,如:a, b, c。

函数的内部有一至多行语句,这些语句并不会立即执行,而只当有其它程序调用它时才执行。这些语句中可能包含“return”语句。在执行一个函数的时候,碰到 return 语句,函数立刻停止执行,并返回到调用它的程序中。如果“return”后带有<值>,则退出函数的同时返回该值。

在函数的内部,参数可以直接当作变量来使用,并可以用 var 语句来新建一些变量,但是这些变量都不能被函数外部的过程调用。要使函数内部的信息能被外部调用,要么使用“return”返回值,要么使用全局变量。

全局变量 在 Script 的“根部”(非函数内部)的“var”语句所定义的变量就是全局变量,它能在整个过程的任意地方被调用、更改。



function addAll(a, b, c) {
    return a + b + c;
}

var total = addAll(3, 4, 5);

这个例子建立了一个叫“addAll”的函数,它有 3 个参数:a, b, c,作用是返回三个数相加的结果。在函数外部,利用“var total = addAll(3, 4, 5);”接收函数的返回值。

更多的时候,函数是没有返回值的,这种函数在一些比较强调严格的语言中是叫做“过程”的,例如 Basic 类语言的“Sub”、Pascal 语言的“procedure”。

属性

arguments 一个数组,反映外部程序调用函数时指定的参数。用法:直接在函数内部调用“arguments”。


网页按钮的特殊颜色
<input type=button name="Submit1" value="郭强" size=10 class=s02 style="background-color:rgb(235,207,22)">

<input type="submit" value="找吧" name="B1" onMouseOut=this.style.color="blue" onMouseOver=this.style.color="red"  class="button">鼠标移入移出时颜色变化


<input type=submit value=订阅 style="border:1px solid :#666666; height:17px; width:25pt; font-size:9pt; BACKGROUND-COLOR: #E8E8FF; color:#666666" name="submit">平面按钮

<input type=text name="nick"  style="border:1px solid #666666;  font-size:9pt;  height:17px; BACKGROUND-COLOR: #F4F4FF; color:#ff6600" size="15" maxlength="16">按钮颜色变化

<input type="text" name="T1" size="20" style="border-style: solid; border-width: 1">平面输入框

<script>
window.resizeTo(300,283);
</script>使窗口变成指定的大小

<marquee direction=up scrollamount=1 scrolldelay=100 onmouseover='this.stop()' onmouseout='this.start()' height=60>
<!-- head_scrolltext -->
<tr>
<td>
共和国
</table>        <!-- end head_scrolltext -->
</marquee>使文字上下滚动

<input type="text" value="郭强" onfocus="if(value=='郭强') {value=''}" onblur="if (value=='') {value='郭强'}">点击时文字消失,失去焦点时文字再出现


<base onmouseover="window.status='缘份DE天空社区 http://www.bbxy.com/bbs/';return true">状态栏显示该页状态


<br>
&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="regtype" value="A03" id="A03">
<label for="A03"> 情侣 : 一次注册两个帐户</label> <br>可以点击文字实现radio选项的选定

可以在文字域的font写onclick事件

<a href='javascript:window.print ()'>打印</a>打印网页

<input type="text" name="key"  size="12" value="关键字" onFocus=this.select() onMouseOver=this.focus() class="line">线型输入框

<script language=javascript>
function hi(str)
{
    document.write(document.lastModified)

    alert("hi"+str+"!")
}
</script>显示文档最后修改日期

<html>
<head>
<script language="LiveScript">
<!-- Hiding
     function hello() {
       alert("哈罗!");
     }
</script>
</head>
<body>
<a href="" onMouseOver="hello()">link</a>
</body>
</html>可以在鼠标移到文字上时就触发事件

<HTML>
<HEAD>
    <TITLE>background.html</TITLE>
</HEAD>
<SCRIPT>
<!--

function bgChange(selObj) {
    newColor = selObj.options[selObj.selectedIndex].text;
    document.bgColor = newColor;
    selObj.selectedIndex = -1;
    }

//-->
</SCRIPT>
<BODY STYLE="font-family:Arial">
<B>Changing Background Colors</B>
<BR>
 <FORM>
     <SELECT SIZE="8" onChange="bgChange(this);">
     <OPTION>Red
     <OPTION>Orange
     <OPTION>Yellow
     <OPTION>Green
     <OPTION>Blue
     <OPTION>Indigo
     <OPTION>Violet
     <OPTION>White
    <OPTION>pink
     </SELECT>
 </FORM>
</BODY>
</HTML>可以根据网页上的选项来确定页面颜色

<style type="text/css">
<!--
.style1 { font-size: 12px; background: #CCCCFF; border-width: thin thin thin thin; border-color: #CCCCFF #CCCCCC #CCCCCC #CCCCFF}
.style2 { font-size: 12px; font-weight: bold; background: #CCFFCC; border-width: thin medium medium thin; border-color: #CCFF99 #999999 #999999 #CCFF99}
-->
</style>
  本例按钮的代码如下:
<input type="submit" name="Submit" value="提 交" onmouseover="this.className='style2'" onmouseout="this.className='style1'" class="style1"> 将按钮的特征改变

<style type="text/css">
<!--
.style3 { font-size: 12px; background: url(image/buttonbg1.gif); border: 0px; width: 60px; height: 22px}
.style4 { font-size: 12px; font-weight: bold; background: url(image/buttonbg2.gif); border: 0px 0; width: 60px; height: 22px}
-->
</style>
  本例的按钮代码如下:
<input type="submit" name="Submit2" value="提 交" onmouseover="this.className='style4'" onmouseout="this.className='style3'" class="style3">
改变按钮的图片.

<div align="center"><a class=content href="javascript:doPrint();">打印本稿</a></div>打印页面

document.write("");可以直接写html语言


<select name="classid" onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1" style="color:#008080;font-size: 9pt"> 改变下拉框的颜色

window.location="http://guoguo"转至目标URL

UpdateSN('guoqiang99267',this.form) 传递该object的form
function UpdateSN(strValue,strForm)
{
  strForm.SignInName.value = strValue;
  return false;
}

<label for="AltName4"><input name="AltName" type="RADIO" tabindex="931"  id="AltName4" >guoqiang99859</label>文字标签

document.all.item('Layer2').style.display = "block";
document.all.item('Layer2').style.display = "none";//layer2为组件的ID,可以控制组件是否可见

<script language=javascript>
<!--
function Addme(){
url = "http://your.site.address"; //你自己的主页地址
title = "Your Site Name"; //你自己的主页名称
window.external.AddFavorite(url,title);
-->
</script>// 将页面加入favorite中


< script language="JavaScript" >
function closeit() {
setTimeout("self.close()",10000)
}
< /script >过10秒自动关闭页面

char=post.charAt(i);
if(!('0'<=char&&char<='9'))可以比较字符的大小

month = parseInt(char)将字符转化为数字

 <select onchange='if(this.value!="")window.open(this.value)' class="textinput">
    <option selected>主办单位</option>
    <option>-----------------</option>
    <option value="http://www.bjd.com.cn/">北京日报</option>
    <option value="http://www.ben.com.cn/">北京晚报</option>
</select>点击value非空的选项时转向指定连接

<td width=* class=dp bgColor=#FAFBFC onmouseover="this.bgColor='#FFFFFF';" onmouseout="this.bgColor='#FAFBFC';">改变背景颜色

<style>
.input2 {background-image: url('../images/inputbg.gif');   font-size: 12px; background-color: #D0DABB;border-top-width:1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
</style>
<input name=content type=text size="47" class="input2" maxlength="50">改变文字输入框的背景颜色

<hr size="0" noshade color="#C0C0C0">改变水平线的特征

<a href="vote.asp?CurPage=8&id=3488">8</a>传递参数的方式

<a href="#1">1</a>
<a href="#2">2</a>
<a href="#3">3</a>
<a href="#4">4</a>
<a href="#5">5</a>
<a href="#6">6</a>
<a href="#7">7</a>
<a name="1">dfdf</a>
<a name="2">dfdf</a>//页内跳转

if(event.ctrlKey && window.event.keyCode==13)//两个按键一起按下

javascript:this.location.reload()//刷新页面

<SCRIPT LANGUAGE="JavaScript">
function haha()
{
    for(var i=0;i<document.form1.elements.length;i++)
    {
        if(document.form1.elements[i].name.indexOf("bb")!=-1)
            document.form1.elements[i].disabled=!document.form1.elements[i].disabled;
    }
}
</SCRIPT>
<BODY><form name=form1>
<INPUT TYPE="button" NAME="aa "  value=cindy onclick=haha()>
<INPUT TYPE="button" NAME="bb " value=guoguo>
<INPUT TYPE="button" NAME="bb " value=guoguo>将网页的按钮使能

<marquee scrollamount=3 onmouseover=this.stop(); onmouseout=this.start();>文字移动

<SCRIPT LANGUAGE="JavaScript">
var currentpos,timer;
function initialize()
{
    timer=setInterval("scrollwindow()",1);
}
function sc()
{
    clearInterval(timer);
}
function scrollwindow()
{
    currentpos=document.body.scrollTop;
    window.scroll(0,++currentpos);
    if (currentpos != document.body.scrollTop)
        sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</SCRIPT>//双击网页自动跑

<INPUT TYPE="button" onclick=window.history.back() value=back>后退
<INPUT TYPE="button" onclick=window.history.forward() value=forward>前进
<INPUT TYPE="button" onclick=document.location.reload() value=reload>刷新

document.location="http://aa.com"或者document.location.assign("http://guoguo.com")转向指定网页

<SCRIPT LANGUAGE="JavaScript">
var clock_id;
window.onload=function()
{
    clock_id=setInterval("document.form1.txtclock.value=(new Date);",1000)
}
</SCRIPT>//在网页上显示实时时间

<script>
document.write("ssdsd");
</script>//页面上打印字

document.location.href="目标文件"//可以下载文件

import java.sql.*;
String myDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(myDBDriver);
Connection conn=DriverManager.getConnection("jdbc:odbc:firm","username","password");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
rs.getString("column1");//连接数据库

<INPUT TYPE="button" onclick="a1.innerHTML='<font color=red>*</font>'">
<div id=a1></div>//可以直接在页面“div”内写下所需内容

<style>
A:link {text-decoration: none; color:#0000FF; font-family: 宋体}
A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}
A:hover {text-decoration: underline overline; color: FF0000}
</style>可以改变页面上的连接的格式,使其为双线

<style>
A:link {text-decoration: none; color:#0000FF; font-family: 宋体}
A:visited {text-decoration: none; color: #0000FF; font-family: 宋体}
A:hover {text-decoration: underline overline line-through; color: FF0000}
TH{FONT-SIZE: 9pt}
TD{FONT-SIZE: 9pt}
body {SCROLLBAR-FACE-COLOR: #A9D46D; SCROLLBAR-HIGHLIGHT-COLOR: #e7e7e7;SCROLLBAR-SHADOW-COLOR:#e7e7e7; SCROLLBAR-3DLIGHT-COLOR: #000000; LINE-HEIGHT: 15pt; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #e7e7e7;}

INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc;
BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}
DIV,form ,OPTION,P,TD,BR{FONT-FAMILY: 宋体; FONT-SIZE: 9pt}
textarea, select {border-width: 1; border-color: #000000; background-color: #efefef; font-family: 宋体; font-size: 9pt; font-style: bold;}
.text { font-family: "宋体"; font-size: 9pt; color: #003300; border: #006600 solid; border-width: 1px 1px 1px 1px}
</style>完整的css

<a href="javascript:newframe('http://www.163.net/help/a_little/index.html','http://www.163.net/help/a_little/a_13.html')"><img alt=帮助 border=0 src="http://bjpic.163.net/images/mail/button-help.gif"></a>新建frame

<%@ page import="java.io.*" %>
<%
    String str = "print me";
    //always give the path from root. This way it almost always works.
    String nameOfTextFile = "/usr/anil/imp.txt";
    try
    {
        PrintWriter pw = new PrintWriter(new FileOutputStream(nameOfTextFile));
        pw.println(str);
        //clean up
        pw.close();
    }
    catch(IOException e)
    {
        out.println(e.getMessage());
    }
%>向文件中写内容

<%@ page language = "java" %>
<%@ page contentType = "text/html; charSet=gb2312" %>
<%@ page import ="java.util.*" %>
<%@ page import ="java.lang.*" %>
<%@ page import ="javax.servlet.*" %>
<%@ page import ="javax.servlet.jsp.*" %>
<%@ page import ="javax.servlet.http.*" %>
<%@ page import="java.io.*" %>
eryrytry
<%
    int count=0;
    FileInputStream fi =new FileInputStream ("count.txt");
    ObjectInputStream si= new ObjectInputStream (fi);
    count =si.readInt();
    count++;
    out.print(count);
    si.close();

    FileOutputStream fo =new FileOutputStream ("count.txt");
    ObjectOutputStream so= new ObjectOutputStream (fo);
    so.writeInt(count);
    so.close();
%>先读文件再写文件

<INPUT name=Password size=10 type=password style="border-left-width: 0; border-right-width: 0; border-top-width: 0; border-bottom-style: solid; border-bottom-width: 1; background-color: #9CEB9C">直线型输入框

<td width="65" align="center" bgcolor="#E0E0E0" onmouseover=this.className='mouseoverbt'; onmouseout=this.className='mouseout';><a href="tm.asp?classid=76"><font color="#000000">录音笔</font></a></td>
<style>
.mouseoverbt
{
    background-image: url(http://www.yongle.com.cn/img/btbgw64h20y.gif);
    background-repeat: no-repeat;
}
.mouseout
{
    background-color: #E0E0E0;
}
</style>可以将背景改为按钮性状,通过改变css改变属性


document.onkeydown=function()
{
if(event.ctrlKey&&event.keyCode==81)
{alert(1)}
}//同时按下CTRL和Q键

---------------------------------------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<style>
#hint{
    width:198px;
    border:1px solid #000000;
    background:#99ff33;
    position:absolute;
    z-index:9;
    padding:6px;
    line-height:17px;
    text-align:left;
    top: 1520px;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function showme()
{
    var oSon=window.document.getElementById("hint");
    if (oSon==null) return;
    with (oSon)
    {
        innerText=guoguo.value;
        style.display="block";
        style.pixelLeft=window.event.clientX+window.document.body.scrollLeft+6;
        style.pixelTop=window.event.clientY+window.document.body.scrollTop+9;
    }
}
function hidme()
{
    var oSon=window.document.getElementById("hint");
    if (oSon==null) return;
    oSon.style.display="none";
}
//-->
</SCRIPT>
<BODY>
<text id=guoguo value=ga>
<a href=# onmouseover=showme() onmouseout=hidme() onmousemove=showme() son=hint>dfdfd</a>
<div id=hint style="display:none"></div>
</BODY>
</HTML>
---------------------------------------------------------------------------------------------------------------------
以上是一个完整的显示hint的代码,其思想是当鼠标停留是将div中的内容显示在鼠标出,当鼠标移出后在将该div隐藏掉

方法一:<body onload="openwen()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwen()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:<a href="#" onclick="openwin()">打开一个窗口</a>
注意:使用的"#"是虚连接。
方法四:用一个按钮调用:<input type="button" onclick="openwin()" value="打开窗口"> 何时装载script

<a name=here>jumpToHere</a>
<a href=#here>jump</a>页面内跳转(用id或者name都可以跳转)

function doZoom(size)
{
   document.getElementById('zoom').style.fontSize=size+'px'
}动态改变字体的大小

function aa()
{
   var newWin=window.open(url);
   newWin.document.form1.text1.value=value1;
}改变弹出窗口上域的属性
opener.document.form2.text2.value=value2;改变父窗口的域的值



javascript与applet通信有两种
javascritp可以访问applet的方法和属性(当然是public的了)
基本方法是酱紫的:
window.document.appletName.appletField
document.appletName.appletMethod()
还可以从applet 里面访问script的对象。
这就要用到两个类
netscape.javascript.JSObject;
netscape.javascritp.JSException;
装了netscape后可在它的java目录下java4.zip里找到。
ie里的文件名比较怪。我用的是ie5 在
/WINNT/Java/Packages/Zpvrtz9r.zip里。


public void init()
{
    String url="jdbc:odbc:javadata";
    try
    {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection(url,"sa","");//mssql database user SA and password
        DatabaseMetaData dma=con.getMetaData();
        System.out.println("Connect to"+dma.getURL());
        System.out.println(";Driver "+dma.getDriverName());
        System.out.println(";Version "+dma.getDriverVersion());
        System.out.println("");
        Statement stmt=con.createStatement();
        ResultSet rs=stmt.executeQuery("select * from company.dbo.TB_NAME where number=1");//Sql
        rs.next();
        String dispresult=rs.getString("name");
        System.out.println(dispresult);// Instead,you can display it in Paint() or use AWT etc.
        rs.close();
        stmt.close();
        con.close();
    }
    catch(SQLException ex)
    {
        System.out.println("!!!SQL Exception !!!");
        while(ex!=null)
        {
            System.out.println("SQLState:"+ex.getSQLState());
            System.out.println("Message:"+ex.getMessage());
            System.out.println("Vendor:"+ex.getErrorCode());
            ex=ex.getNextException();
            System.out.println("");
        }

    }
    catch(java.lang.Exception ex)
    {
        ex.printStackTrace();
    }
}//java中建立数据库连接取数据


import java.awt.*;
public class print
{
    public static void main(String args[])
    {
        Frame f = new Frame("tet");
        f.pack( );
        PrintJob pj = f.getToolkit().getPrintJob(f, "print1", null);
        if( pj != null)
        {
            Graphics g = pj.getGraphics( );
            g.fillOval(5,5,150,100);
            g.dispose( );
            pj.end();
        }
        System.exit(0);
    }
}//用java实现打印


var name = navigator.appName;
if (name == "Microsoft Internet Explorer")
    alert("IE");
else if (name == "Netscape")
    alert("NS");//判断是何种浏览器


document.write("<BGSOUND SRC='break my heart.MP3' LOOP=INFINITE>");
document.write("<EMBED SRC=canyon.mid AUTOSTART=TRUE ");//插入北京音乐,文件类型可以是*.mid,*.wav,*.mp3

window.status="status";//状态栏显示文字

oDiv.style.setExpression("left","document.body.clientWidth/2 - oDiv.offsetWidth/2");
oDiv.style.setExpression("top","document.body.clientHeight/2 - oDiv.offsetHeight/2");

<DIV ID="oDiv" STYLE="position: absolute"; top: 0; left: 0>Example DIV</DIV>//动态设置属性值


<body onkeydown="return !(event.keyCode==78&&event.ctrlKey)">//键盘同时按下CTRL+N

<select id=a1>
<option>1
<option>2
<option>3
</select>
<script>
a1.options[2].removeNode(true); //删除第三个,如果删除第二个,就用options[1]
</script>//删除某下拉框中的某一项


<script language="VBScript">
<!--
MsgBox "确定删除吗?", 4   
//-->
</script>//vbsscript确定框


function JM_cc(bb)
{
    var ob=eval("document.form1."+bb);
    ob.select();
    js=ob.createTextRange();
    js.execCommand("Copy");
}//复制内容到剪切板


<input type="button" name="Button" value="查看当前页面的源代码" onClick= 'window.location = "view-source:" + window.location.href'>//察看源代码


window.blur()//最小化窗口


var s=document.createElement("INPUT")
form1.appendChild(s)
s.value="ss"//动态创建tag
s.name="guoguo";
s.id="myid";


<BODY oncontextmenu="window.close();return false;">//在页面上点击右键是触发

document.URL//文档的路径


setTimeout("change_color()",600);定时执行某段程序

function makeHome(){
  netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
  navigator.preference("browser.startup.homepage", location.href);
}//设置为主页

function addFav(){
  if(ie)
    window.external.AddFavorite(location.href,'WWW.OGRISH.COM : GROTESQUE MOVIES AND PICTURES');
  if(ns)
    alert("Thanks for the bookmark!/n/nNetscape users click OK then press CTRL-D");
}//设置为收藏


navigator.cookieEnabled;//判断cookie是否可用


function setbgcolor_onclick()
{
    var color = showModalDialog("/mailpage/compose/colorsel.html",0,"help=0");
    if (color != null)
    {
        document.compose.bgcolor.value = color;
    }
}//显示有模式的有页面的弹出窗口


window.external.AddFavorite('http://www.5dmedia.com', "5D多媒体");//加入favourite文件夹中
onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.5dmedia.com');return false;" //设置为默认主页


var a=3454545.4454545;
alert(a.toFixed(2));//截取小数点后两位


1234567890<input type="button" value="查找5" onClick="findInPage(6)">
<script language="JavaScript">
function findInPage(str){
r = document.body.createTextRange();
r.findText(str);
r.select();
}
</script>//页内查找,仅适用于BODY, BUTTON, INPUT TYPE=button, INPUT TYPE=hidden, INPUT TYPE=password, INPUT TYPE=reset, INPUT TYPE=submit, INPUT TYPE=text, TEXTAREA


<object id=minimize type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="MINIMIZE">
</object>
<a href="#" onClick=minimize.Click()>最小化窗口</a>//最小化窗口
<object id=maximize type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="MAXIMIZE">
</object>
<a href="#" onClick=maximize.Click()>最大化窗口</a> //最大化窗口


<script>
function noEffect() {
  with (event) {
    returnValue = false;
    cancelBubble = true;
  }
  return;
}
</script>
<body onselectstart="noEffect()" oncontextmenu="noEffect()">//禁止选择页面上的文字来拷贝


oncontextmenu="event.returnValue = false"//屏蔽右键菜单
event.cancelBubble = true//事件禁止起泡


<input style="ime-mode: disabled">//禁止在输入框打开输入法


<input name="txt"><input type="submit" onClick="alert(!/[^ -}]|/s/.test(txt.value))">//屏蔽汉字和空格


function Exists(filespec)
{
    if (filespec)
    {
        var fso;
        fso = new ActiveXObject("Scripting.FileSystemObject");
        alert(fso.FileExists(filespec));
    }
}
选择图片 <input type=file name=f1><p>
<input type="submit" onClick="Exists(f1.value)">//用javascript判断文件是否存在


<input onmouseup="alert(document.selection.createRange().text)" value=123>//获得当前的文本框选中的文字


<a href="javascript:location.replace('http://www.sohu.com/')">sohu.com</a>//跳转至目标页面,同时不可返回



<script>
function getrow(obj)
{
   if(event.srcElement.tagName=="TD"){
   curRow=event.srcElement.parentElement;
   alert("这是第"+(curRow.rowIndex+1)+"行");

   }
}
</script>

<table border="1" width="100%" onclick=getrow(this)>
  <tr>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
  </tr>
  <tr>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
  </tr>
</table>//获得当前的行是表格的第几行


document.all.myTable.deleteRow(xx)//删除表格某行,xx表示某行,下标从0开始计算


<table id="t1" border="1">
</table>
<script language="JavaScript">
function add()
{
   t1.insertRow().insertCell().innerHTML = '<input name="test'+t1.rows.length+'">';
}//动态的向表格中添加行



event.x,event.clientX,event.offsetX区别:
x:设置或者是得到鼠标相对于目标事件的父元素的外边界在x坐标上的位置。 clientX:相对于客户区域的x坐标位置,不包括滚动条,就是正文区域。 offsetx:设置或者是得到鼠标相对于目标事件的父元素的内边界在x坐标上的位置。
screenX:相对于用户屏幕。



<body onMouseDown="alert(event.button)">点Mouse看看//显示是鼠标按钮的哪个


<form action="file:///c|/"><input type="submit" value="c:/ drive"></form>//打开C盘


<body onunload="bookmark()">//退出时进行的操作



screen.width、screen.height//当前屏幕的分辨率


<input type=text name=txtPostalCode onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">//只能输入数字


tbl.rows[0].cells[1].innerText=document.form.text1.value;//设置表格中的内容



<p><a href="file:///::{208D2C60-3AEA-1069-A2D7-08002B30309D}" target="_blank">网上邻居</a></p>
<p><a href="file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/d:/web" target="_blank">我的电脑</a></p>
<p><a href="file:///::{450D8FBA-AD25-11D0-98A8-0800361B1103}" target="_blank">我的文档</a></p>
<p><a href="file:///::{645FF040-5081-101B-9F08-00AA002F954E}" target="_blank">回收站</a></p>
<p><a href="file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/::{21EC2020-3AEA-1069-A2DD-08002B30309D}" target="_blank">控制面板</a></p>
<p><a href="file:///::{7007ACC7-3202-11D1-AAD2-00805FC1270E}">拨号网络</a>(windows 2000)</p>



 onClick= 'window.location = "view-source:" + window.location.href'//看源代码



<button onclick="min.Click()"><font face="webdings">0</font></button>//改变按钮上的图片
<input type=button  onclick="document.execCommand('CreateLink','true','true')"> //创建新连接
<input type=button  onclick="document.execCommand('print','true','true')"> //打印
<input type=button  onclick="document.execCommand('saveas','true','海娃在线.htm')">//另存为htm
<input type=button  onclick="document.execCommand('saveas','true','海娃在线.txt')">//另存为txt


<SCRIPT>
var contents='<style>body,td{font:menu}img{cursor:hand}</style>';
contents+='<title>你要关闭我吗</title>';
contents+='<body bgcolor=menu>';
contents+='<table width=100% height=100% border=0>';
contents+='<tr><td align=center>';
contents+='你要关闭我吗?<br>';
contents+='<img src=dark.gif onclick=self.close() alt="...关闭">';
contents+='<img src=jet.gif onclick=self.close() alt="全是关闭">';
contents+='</td></tr></table>';
showModalDialog("about:"+contents+"","","dialogHeight:50px;dialogWidth:250px;help:no;status:no")
document.write(contents);
</SCRIPT>//web对话框


<button onclick="t1.rows[x].cells[y].innerText='guoguo'"></button>//取第x,y的值


newwin=window.open('about:blank','','top=10');
newwin.document.write('');//向新打开的网页上写内容


javascript:history.go(-2);//返回


abcdefg
<input type='button' onclick="window.clipboardData.setData('text',document.selection.createRange().text);" value='复制页面选中的字符'>//将页面上选中的内容复制到剪贴板
<INPUT TYPE="text" NAME="">kjhkjhkhkj<INPUT TYPE="button" onclick="document.execCommand('Copy', 'false', null);">////将页面上选中的内容复制到剪贴板

<select onmouseover="javascript:this.size=this.length" onmouseout="javascript:this.size=1"></select>//鼠标移到下拉框时自动全部打开


var fso = new ActiveXObject("Scripting.FileSystemObject");
var f1 = fso.GetFile("C://bsitcdata//ejbhome.xml");
alert("File last modified: " + f1.DateLastModified); //获得本机的文件


<input type="button" value="Save As" onclick="txt.location.href='51js.txt';txt.document.execCommand('SaveAs',true,'text.txt')">//文件另存为


因为 document.all 是 IE 的特有属性,所以通常用这个方法来判断客户端是否是IE浏览器 ,document.all?1:0;


new Option(text,value)这样的函数//创建新的下拉框选项


<STYLE>
td{font-size:12px}
body{font-size:12px}
v/:*{behavior:url(#default#VML);} //这里声明了v作为VML公用变量
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
mathstr=12;
document.write ("<v:rect fillcolor='red' style='width:20;color:navy;height:"+5000/(1000/mathstr)+"'><br>&nbsp;%"+mathstr+"<br>4人<v:Extrusion backdepth='15pt' on='true'/></v:rect>")
</SCRIPT>
<v:rect fillcolor='red' style='width:20;color:navy;height:200'><br>%12<br>4人<v:Extrusion backdepth='15pt' on='true'/></v:rect>
<v:rect fillcolor='yellow' style='width:20;color:navy;height:100'><br>%12<br>4人<v:Extrusion backdepth='15pt' on='true'/></v:rect>//在页面上画柱状图




<style>
v/:*     { behavior: url(#default#VML) }
o/:*     { behavior: url(#default#VML) }
.shape    { behavior: url(#default#VML) }
</style>
<script language="javascript">
function show(pie)
{
pie.strokecolor=pie.fillcolor;
pie.strokeweight=10;
div1.innerHTML="<font size=2 color=red> " + pie.id +"</font> <font size=2>" + pie.title + "</font>";
}
function hide(pie)
{
pie.strokecolor="white";
pie.strokeweight=1;
div1.innerHTML="";
}
</script>
</head>
<body>
<v:group style='width: 5cm; height: 5cm' coordorigin='0,0' coordsize='250,250'>
<v:shape id='asp技术' style='width:10;height:10;top:10;left:0' title='得票数:6 比例:40.00%' onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' CoordSize='10,10' strokecolor='white' fillcolor='#ffff33'><v:path v='m 300,200 ae 300,200,200,150,0,9437184 xe'/></v:shape>
<v:shape id='php' style='width:10;height:10;top:10;left:0' title='得票数:1 比例:6.67%' onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' CoordSize='10,10' strokecolor='white' fillcolor='#ff9933'><v:path v='m 300,200 ae 300,200,200,150,9437184,1572864 xe'/></v:shape>
<v:shape id='jsp' style='width:10;height:10;top:10;left:0' title='得票数:2 比例:13.33%' onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' CoordSize='10,10' strokecolor='white' fillcolor='#3399ff'><v:path v='m 300,200 ae 300,200,200,150,11010048,3145728 xe'/></v:shape>
<v:shape id='c#写的.netWEB程序' style='width:10;height:10;top:10;left:0' title='得票数:3 比例:20.00%' onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' CoordSize='10,10' strokecolor='white' fillcolor='#99ff33'><v:path v='m 300,200 ae 300,200,200,150,14155776,4718592 xe'/></v:shape>
<v:shape id='vb.net写的.netWEB程序' style='width:10;height:10;top:10;left:0' title='得票数:2 比例:13.33%' onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' CoordSize='10,10' strokecolor='white' fillcolor='#ff6600'><v:path v='m 300,200 ae 300,200,200,150,18874368,3145728 xe'/></v:shape>
<v:shape id='xml技术' style='width:10;height:10;top:10;left:0' title='得票数:1 比例:6.67%' onmouseover='javascript:show(this);' onmouseout='javascript:hide(this);' href='http://www.cnADO.com' CoordSize='10,10' strokecolor='white' fillcolor='#ff99ff'><v:path v='m 300,200 ae 300,200,200,150,22020096,1572864 xe'/></v:shape>
</v:group>

<v:group style='width: 6cm; height: 6cm' coordorigin='0,0' coordsize='250,250'>
<v:rect style='height:10;width:15;top:0;left:10' fillcolor='#ffff33'/>
<v:rect style='height:28;width:100;top:0;left:30' stroked='false'><v:textbox style='fontsize:2'>asp技术</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:30;left:10' fillcolor='#ff9933'/>
<v:rect style='height:28;width:100;top:30;left:30' stroked='false'><v:textbox style='fontsize:2'>php</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:60;left:10' fillcolor='#3399ff'/>
<v:rect style='height:28;width:100;top:60;left:30' stroked='false'><v:textbox style='fontsize:2'>jsp</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:90;left:10' fillcolor='#99ff33'/>
<v:rect style='height:28;width:100;top:90;left:30' stroked='false'><v:textbox style='fontsize:2'>c#写的.netWEB程序</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:120;left:10' fillcolor='#ff6600'/>
<v:rect style='height:28;width:100;top:120;left:30' stroked='false'><v:textbox style='fontsize:2'>vb.net写的.netWEB程序</v:textbox/></v:rect>
<v:rect style='height:10;width:15;top:150;left:10' fillcolor='#ff99ff'/>
<v:rect style='height:28;width:100;top:150;left:30' stroked='false'><v:textbox style='fontsize:2'>xml技术</v:textbox/></v:rect>
</v:group>

<div style="position: absolute; left: 10; top: 10; width: 760; height:16">
 <table border="1" cellpadding="2" cellspacing="2" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#CCCCCC" width="100%" ID="Table1">
  <tr>
   <td width="100%" id=div1> </td>
  </tr>
 </table>
</div>//饼图

<button><iframe src="http://www.google.com/"></iframe></button>//button 是一个特殊的容器,想装个网页都行

event.srcElement.outerHTML//外部的html代码
event.srcElement和event.keyCode标识当前的IE事件的触发器
event.type//事件类型


<style>
.Overnone { border-width:0;background-color:darkblue;cursor:default;color:gold;width:115}
.Outnone   {border-width:0;background-color:white;cursor:default;width:115}
</style>
<input class=Outnone onmouseover=this.className='Overnone' >//动态改变类型


<html dir=rtl></html>//页面翻转


parent.scroll(x,y);//滚屏


self.status ="";//改变状态栏


window.resizeTo(200,300);//改变窗口大小


style
BODY{CURSOR: url('mouse.ani');
SCROLLBAR-BASE-COLOR: #506AA8;
SCROLLBAR-ARROW-COLOR: #14213F;
}//改变鼠标样式


<input type="button" value="Button" style="background-color: transparent; border: 0;">//背景透明


<input type=button onclick="this.style.cursor='wait'">//鼠标为等待形状

onkeydown="if(event.shiftKey&&event.keyCode==9)event.keyCode=39"//同时按下shift和别的按钮


opener.fucntion1();//调用父窗口的函数


<input type="button" onclick="alert(code.document.body.innerHTML)" value="查看">//body的内部html代码


<INPUT TYPE='button' onclick='parent.test();' value='调用parent窗口的函数'>//框架中调用父窗口的函数


<table  width=200  height=200  border>
<tr><td  id=c1>CELL_1</td></tr>
<tr><td  id=c2>CELL_2</td></tr>
</table>
<br>
<input  type="button"  value="swap  row"  onclick="c1.swapNode(c2)">//交换节点


<table  width=200  height=200  border>
<tr id=trall><td  id=c1>CELL_1</td></tr>
<tr><td  id=c2>CELL_2</td></tr>
</table>
<br>
<input  type="button"  value="swap  row"  onclick="trall.removeNode(c2)">//删除节点

addNode()//添加节点


event.srcElement.children[0]和event.srcElement.parentElement //获得事件的父与子标签



<style>
button{benc:expression(this.onfocus = function(){this.style.backgroundColor='#E5F0FF';})}
</style>
<button>New</button>//集中为按钮改变颜色



window.open('file:///C:/bsitcdata/system3.xml');//打开本地文件



alert("星期"+"日一二三四五六".split("")[new Date().getDay()])//显示当前是星期几


<body onmousedown=if(event.button==1)alert("左键");if(event.button==2)alert("右键")>//判断是左键还是右键被按下


document.write(navigator.userAgent)//获得操作系统的名称和浏览器的名称



event.altKey //按下alt键
event.ctrlKey //按下ctrl键
event.shiftKey //按下shift键



<body onload="s=0" onDblClick="s=setInterval('scrollBy(0, 1)',10)" onClick="clearInterval(s)">//滚屏


{window.location="c:"}//将当前位置定位为C盘。


<script>
alert(event.srcElement.type);//返回输入框的类型
</script>


<INPUT TYPE="hidden" name="guoguo" onclick="haha()">
<SCRIPT LANGUAGE="JavaScript">
<!--

function haha()
{
    alert();
}
guoguo.click();
//-->
</SCRIPT>//模拟控件的单击事件



java.sql.ResultSet rset = com.bsitc.util.DBAssist.getIT().executeQuery(queryStatement, conn);
java.sql.ResultSetMetaData metaData = rset.getMetaData();
int count = metaData.getColumnCount();
String name = metaData.getColumnName(i);
String value = rset.getString(i);//取出记录集的列名




格式化数字
function format_number(str,digit)
{
    if(isNaN(str))
    {
        alert("您传入的值不是数字!");
        return 0;
    }
    else if(Math.round(digit)!=digit)
    {
        alert("您输入的小数位数不是整数!");
        return 0;
    }
    else
        return Math.round(parseFloat(str)*Math.pow(10,digit))/Math.pow(10,digit);
}



inputID.removeNode(true)//删除子节点




if(event.keyCode==13) event.keyCode=9; //将回车按钮转化为tab按钮



<button onclick="text1.scrollTop=text1.scrollHeight">Scroll</button><br>
<textarea id="text1" cols=50 rows=10>
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
</textarea>//滚动条滚动



if(typeof(unknown)=="function")return true;
if(typeof(unknown)!="object")return false;//判断是什么对象



<input type="text" autocomplete="off"> //取消文本框自动完成功能




<select onmouseover="javascript:this.size=this.length" onmouseout="javascript:this.size=1">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select> //让下拉框自动下拉



var childrenobj=myselect//document.all.myselect;
    var oXMLDoc = new ActiveXObject('MSXML');
    oXMLDoc.url = "mymsg.xml";
    var oRoot=oXMLDoc.root;
    if(oRoot.children != null)
    {
        for(var i=0;i<oRoot.children.item(0).children.length;++i)
        {
            oItem = oRoot.children.item(0).children.item(i);
            oOption = new Option(oItem.text,oItem.value);
            childrenobj.add(oOption);
        }
    }


//mymsg.xml文件
<?xml version="1.0" encoding="gb2312" ?>
<childrenlist>
<aa>
<child value='3301'>杭州地区</child>

<child value='3303'>温州地区</child>

</aa>
<aa>
<child value='3310'>台州地区</child>

<child value='3311'>丽水地区</child>
</aa>
</childrenlist>//读取XML文件



<a href="javascript:"><img src="http://www.51js.com/images/51js/red_forum.gif" border="0"></a>//点击图片,图片停止


var WshNetwork = new ActiveXObject("WScript.Network");
alert("Domain = " + WshNetwork.UserDomain);
alert("Computer Name = " + WshNetwork.ComputerName);
alert("User Name = " + WshNetwork.UserName);//显示本地计算机信息



  tDate = new Date(2004,01,08,14,35); //年,月,日,时,分
  dDate = new Date();
  tDate<dDate?alert("早于"):alert("晚于");//比较时间


  <body onmouseover="if (event.srcElement.tagName=='A')alert(event.srcElement.href)"><a href="http://51js.com/viewthread.php?tid=13589" >dddd</a><input>//弹出鼠标所在处的链结地址


注意不能通过与 undefined 做比较来测试一个变量是否存在,虽然可以检查它的类型是否为“undefined”。在以下的代码范例中,假设程序员想测试是否已经声明变量 x :
// 这种方法不起作用
if (x == undefined)
    // 作某些操作
// 这个方法同样不起作用- 必须检查


// 字符串 "undefined"
if (typeof(x) == undefined)
    // 作某些操作
// 这个方法有效
if (typeof(x) == "undefined")
    // 作某些操作





// 创建具有某些属性的对象
var myObject = new Object();
myObject.name = "James";
myObject.age = "22";
myObject.phone = "555 1234";

// 枚举(循环)对象的所有属性
for (var a in myObject)
{
    // 显示 "The property 'name' is James",等等。
    window.alert("The property '" + a + "' is " + myObject[a]);
}


var a=23.2;
alert(a%1==1)//判断一个数字是否是整数


新建日期型变量
var a = new Date(2000, 1, 1);
alert(a.toLocaleDateString());


给类定义新的方法
function trim_1()
{
     return this.replace(/(^/s*)|(/s*$)/g, "");
}
String.prototype.trim=trim_1;
alert('cindy'.trim());



定义一个将日期类型转化为字符串的方法
function guoguo_date()
{
    var tmp1,tmp2;
    tmp1    =this.getMonth()+1+"";
    if(tmp1.length<2)
        tmp1="0"+tmp1;
    tmp2    =this.getDate()+"";
    if(tmp2.length<2)
        tmp2="0"+tmp2;
   
    return this.getYear()+"-"+tmp1+"-"+tmp2;
}
Date.prototype.toLiteString=guoguo_date;
alert(new Date().toLiteString())



// pasta 是有四个参数的构造器,定义对象。
function pasta(grain, width, shape, hasEgg)
{
    // 是用什么粮食做的?
    this.grain = grain;

    // 多宽?(数值)
    this.width = width;    

    // 横截面形状?(字符串)
    this.shape = shape;  

    // 是否加蛋黄?(boolean)
    this.hasEgg = hasEgg; 

    //定义方法
    this.toString=aa;
}
function aa()
{
    ;
}
//定义了对象构造器后,用 new 运算符创建对象实例。
var spaghetti = new pasta("wheat", 0.2, "circle", true);
var linguine = new pasta("wheat", 0.3, "oval", true);
//补充定义属性,spaghetti和linguine都将自动获得新的属性
pasta.prototype.foodgroup = "carbohydrates";



try
{
    x = y   // 产生错误。
}
catch(e)
{
   document.write(e.description)   //打印 "'y' is undefined".
}//打印出错误原因









var ExcelSheet;
ExcelApp = new ActiveXObject("Excel.Application");
ExcelSheet = new ActiveXObject("Excel.Sheet");
//本代码启动创建对象的应用程序(在这种情况下,Microsoft Excel 工作表)。一旦对象被创建,就可以用定义的对象变量在代码中引用它。 在下面的例子中,通过对象变量 ExcelSheet 访问新对象的属性和方法和其他 Excel 对象,包括 Application 对象和 ActiveSheet.Cells 集合。
// 使 Excel 通过 Application 对象可见。
ExcelSheet.Application.Visible = true;
// 将一些文本放置到表格的第一格中。
ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
// 保存表格。
ExcelSheet.SaveAs("C://TEST.XLS");
// 用 Application 对象用 Quit 方法关闭 Excel。
ExcelSheet.Application.Quit();//生成EXCEL文件并保存





var coll = document.all.tags("DIV");
if (coll!=null)
{
for (i=0; i<coll.length; i++)
...
}//根据标签获得一组对象
   


<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<input type=button value=打印预览 onclick="wb.execwb(7,1)">
<input type=button onClick=document.all.wb.ExecWB(6,1) value="打印">//实现打印预览及打印


<INPUT TYPE="text" NAME="gg" value=aaaaa>
<SCRIPT LANGUAGE="JavaScript">
<!--
alert(document.all.gg.value)
//-->
</SCRIPT>//不通过form,直接通过名字引用对象





function document.onmousewheel()
{
 return false;
}//使鼠标滚轮失效



<SCRIPT LANGUAGE="JScript">
  var oPopup = window.createPopup();
  var oPopupBody = oPopup.document.body;
  oPopupBody.innerHTML = "Display some <B>HTML</B> here.";
  oPopup.show(100, 100, 200, 50, document.body);
</SCRIPT>//创建弹出窗口




document.execCommand("SaveAs")//保存为
document.execCommand('undo')//撤销上一次操作



var obj = document.elementFromPoint(event.x,event.y);//取得鼠标所在处的对象


<INPUT TYPE="text" NAME="gg"><INPUT TYPE="text" NAME="bb" onclick="this.previousSibling.value='guoguo'">//获得左边的对象



document.all.hint_layer.style.left        =    event.x+document.body.scrollLeft+10;
document.all.hint_layer.style.top        =    event.y+document.body.scrollTop+10;//定位鼠标




var op        =    document.createElement("OPTION");
document.all.selected_items.children(index).insertAdjacentElement("BeforeBegin",op);
op.text        =    document.all.all_items[i].text;
op.value    =    document.all.all_items[i].value;//向下拉框指定位置添加项目



var a;
if(a)   
    a.close();
else
    a=window.open('','','');//判断一个窗口是否已经打开,如果已经打开,则关闭之




newElem        =    document.createElement("DIV");
newElem.id    =    "hint_layer";
document.body.appendChild(newElem);
document.all.hint_layer.innerText="guoguo";//动态创建一个标签




document.title//标题栏



<body style="BACKGROUND-ATTACHMENT: fixed" background="img/bgfix.gif" ></body>//背景图片不动




<STYLE TYPE="text/css">
<!--
BODY {background-image:img/bgchild.jpg;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;}
-->
</STYLE>//背景图片居中



scroll(0,0);//页面自动滚动



document.form.xxx.filters.alpha.opacity=0~100//设置透明效果


var dragapproved=false;
document.onmouseup=new Function("dragapproved = false");//定义方法



function convertCurrency(currencyDigits) {
// Constants:
 var MAXIMUM_NUMBER = 99999999999.99;
 // Predefine the radix characters and currency symbols for output:
 var CN_ZERO = "零";
 var CN_ONE = "壹";
 var CN_TWO = "贰";
 var CN_THREE = "叁";
 var CN_FOUR = "肆";
 var CN_FIVE = "伍";
 var CN_SIX = "陆";
 var CN_SEVEN = "柒";
 var CN_EIGHT = "捌";
 var CN_NINE = "玖";
 var CN_TEN = "拾";
 var CN_HUNDRED = "佰";
 var CN_THOUSAND = "仟";
 var CN_TEN_THOUSAND = "万";
 var CN_HUNDRED_MILLION = "亿";
 var CN_SYMBOL = "人民币";
 var CN_DOLLAR = "元";
 var CN_TEN_CENT = "角";
 var CN_CENT = "分";
 var CN_INTEGER = "整";
 
// Variables:
 var integral; // Represent integral part of digit number.
 var decimal; // Represent decimal part of digit number.
 var outputCharacters; // The output result.
 var parts;
 var digits, radices, bigRadices, decimals;
 var zeroCount;
 var i, p, d;
 var quotient, modulus;
 
// Validate input string:
 currencyDigits = currencyDigits.toString();
 if (currencyDigits == "") {
  alert("Empty input!");
  return "";
 }
 if (currencyDigits.match(/[^,./d]/) != null) {
  alert("Invalid characters in the input string!");
  return "";
 }
 if ((currencyDigits).match(/^((/d{1,3}(,/d{3})*(.((/d{3},)*/d{1,3}))?)|(/d+(./d+)?))$/) == null) {
  alert("Illegal format of digit number!");
  return "";
 }
 
// Normalize the format of input digits:
 currencyDigits = currencyDigits.replace(/,/g, ""); // Remove comma delimiters.
 currencyDigits = currencyDigits.replace(/^0+/, ""); // Trim zeros at the beginning.
 // Assert the number is not greater than the maximum number.
 if (Number(currencyDigits) > MAXIMUM_NUMBER) {
  alert("Too large a number to convert!");
  return "";
 }
 
// Process the coversion from currency digits to characters:
 // Separate integral and decimal parts before processing coversion:
 parts = currencyDigits.split(".");
 if (parts.length > 1) {
  integral = parts[0];
  decimal = parts[1];
  // Cut down redundant decimal digits that are after the second.
  decimal = decimal.substr(0, 2);
 }
 else {
  integral = parts[0];
  decimal = "";
 }
 // Prepare the characters corresponding to the digits:
 digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
 radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
 bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
 decimals = new Array(CN_TEN_CENT, CN_CENT);
 // Start processing:
 outputCharacters = "";
 // Process integral part if it is larger than 0:
 if (Number(integral) > 0) {
  zeroCount = 0;
  for (i = 0; i < integral.length; i++) {
   p = integral.length - i - 1;
   d = integral.substr(i, 1);
   quotient = p / 4;
   modulus = p % 4;
   if (d == "0") {
    zeroCount++;
   }
   else {
    if (zeroCount > 0)
    {
     outputCharacters += digits[0];
    }
    zeroCount = 0;
    outputCharacters += digits[Number(d)] + radices[modulus];
   }
   if (modulus == 0 && zeroCount < 4) {
    outputCharacters += bigRadices[quotient];
   }
  }
  outputCharacters += CN_DOLLAR;
 }
 // Process decimal part if there is:
 if (decimal != "") {
  for (i = 0; i < decimal.length; i++) {
   d = decimal.substr(i, 1);
   if (d != "0") {
    outputCharacters += digits[Number(d)] + decimals[i];
   }
  }
 }
 // Confirm and return the final output string:
 if (outputCharacters == "") {
  outputCharacters = CN_ZERO + CN_DOLLAR;
 }
 if (decimal == "") {
  outputCharacters += CN_INTEGER;
 }
 outputCharacters = CN_SYMBOL + outputCharacters;
 return outputCharacters;
}//将数字转化为人民币大写形式



<html>
<body>
<xml id="abc" src="test.xml"></xml>
<table border='1' datasrc='#abc'>
<thead>
<td>接收人</td>
<td>发送人</td>
<td>主题</td>
<td>内容</td>
</thead>
<tfoot>
<tr><th>表格的结束</th></tr>
</tfoot>
<tr>
<td><div datafld="to"></div></td>
<td><div datafld="from"></div></td>
<td><div datafld="subject"></div></td>
<td><div datafld="content"></div></td>
</tr>
</table>
</body>
</html>

//cd_catalog.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
 <!--  Edited with XML Spy v4.2
  -->
 <CATALOG>
 <CD>
  <TITLE>Empire Burlesque</TITLE>
  <ARTIST>Bob Dylan</ARTIST>
  <COUNTRY>USA</COUNTRY>
  <COMPANY>Columbia</COMPANY>
  <PRICE>10.90</PRICE>
  <YEAR>1985</YEAR>
  </CD>
 <CD>
  <TITLE>Hide your heart</TITLE>
  <ARTIST>Bonnie Tyler</ARTIST>
  <COUNTRY>UK</COUNTRY>
  <COMPANY>CBS Records</COMPANY>
  <PRICE>9.90</PRICE>
  <YEAR>1988</YEAR>
  </CD>
 <CD>
  <TITLE>Greatest Hits</TITLE>
  <ARTIST>Dolly Parton</ARTIST>
  <COUNTRY>USA</COUNTRY>
  <COMPANY>RCA</COMPANY>
  <PRICE>9.90</PRICE>
  <YEAR>1982</YEAR>
  </CD>
 <CD>
  <TITLE>Still got the blues</TITLE>
  <ARTIST>Gary Moore</ARTIST>
  <COUNTRY>UK</COUNTRY>
  <COMPANY>Virgin records</COMPANY>
  <PRICE>10.20</PRICE>
  <YEAR>1990</YEAR>
  </CD>
</CATALOG>
//xml数据岛绑定表格


//以下组合可以正确显示汉字
================================
xml保存编码    xml页面指定编码
ANSI        gbk/GBK、gb2312
Unicode        unicode/Unicode
UTF-8        UTF-8
================================



<xml id="xmldata" src="/data/books.xml">
<div id="guoguo"></div>
<script>
var x=xmldata.recordset    //取得数据岛中的记录集
if(x.absoluteposition < x.recordcount)    //如果当前的绝对位置在最后一条记录之前
{
    x.movenext();                    //向后移动
    x.moveprevious();                //向前移动
    x.absoluteposition=1;            //移动到第一条记录
    x.absoluteposition=x.recordcount;//移动到最后一条记录,注意记录集x.absoluteposition是从1到记录集记录的个数的
    guoguo.innerText=xmldso.recordset("field_name");    //从中取出某条记录
}
</script>



this.runtimeStyle.cssText = "color:#990000;border:1px solid #cccccc";//动态修改CSS的另一种方式

==================正则表达式
匹配中文字符的正则表达式: [/u4e00-/u9fa5]

匹配双字节字符(包括汉字在内):[^/x00-/xff]

应用:计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)

String.prototype.len=function(){return this.replace([^/x00-/xff]/g,"aa").length;}

匹配空行的正则表达式:/n[/s| ]*/r

匹配HTML标记的正则表达式:/<(.*)>.*<///1>|<(.*) //>/

匹配首尾空格的正则表达式:(^/s*)|(/s*$)

应用:javascript中没有像vbscript那样的trim函数,我们就可以利用这个表达式来实现,如下:

String.prototype.trim = function()
{
    return this.replace(/(^/s*)|(/s*$)/g, "");
}

利用正则表达式分解和转换IP地址:

下面是利用正则表达式匹配IP地址,并将IP地址转换成对应数值的Javascript程序:

function IP2V(ip)
{
 re=/(/d+)/.(/d+)/.(/d+)/.(/d+)/g  //匹配IP地址的正则表达式
if(re.test(ip))
{
return RegExp.$1*Math.pow(255,3))+RegExp.$2*Math.pow(255,2))+RegExp.$3*255+RegExp.$4*1
}
else
{
 throw new Error("Not a valid IP address!")
}
}

不过上面的程序如果不用正则表达式,而直接用split函数来分解可能更简单,程序如下:

var ip="10.100.20.168"
ip=ip.split(".")
alert("IP值是:"+(ip[0]*255*255*255+ip[1]*255*255+ip[2]*255+ip[3]*1))

匹配Email地址的正则表达式:/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*

匹配网址URL的正则表达式:http://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?

利用正则表达式去除字串中重复的字符的算法程序:

var s="abacabefgeeii"
var s1=s.replace(/(.).*/1/g,"$1")
var re=new RegExp("["+s1+"]","g")
var s2=s.replace(re,"")
alert(s1+s2)  //结果为:abcefgi

我原来在CSDN上发贴寻求一个表达式来实现去除重复字符的方法,最终没有找到,这是我能想到的最简单的实现方法。思路是使用后向引用取出包括重复的字符,再以重复的字符建立第二个表达式,取到不重复的字符,两者串连。这个方法对于字符顺序有要求的字符串可能不适用。

得用正则表达式从URL地址中提取文件名的javascript程序,如下结果为page1

s="http://www.9499.net/page1.htm"
s=s.replace(/(.*//){0,}([^/.]+).*/ig,"$2")
alert(s)

利用正则表达式限制网页表单里的文本框输入内容:

用正则表达式限制只能输入中文:onkeyup="value=value.replace(/[^/u4E00-/u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/u4E00-/u9FA5]/g,''))"

用正则表达式限制只能输入全角字符: onkeyup="value=value.replace(/[^/uFF00-/uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/uFF00-/uFFFF]/g,''))"

用正则表达式限制只能输入数字:onkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"

用正则表达式限制只能输入数字和英文:onkeyup="value=value.replace(/[/W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"



<HTML>
<BODY>
设置与读取 cookies...<BR>
写入cookie的值<input type=text name=gg>
<INPUT TYPE = BUTTON Value = "设置cookie" onClick = "Set()">
<INPUT TYPE = BUTTON Value = "读取cookie" onClick = "Get()"><BR>
<INPUT TYPE = TEXT NAME = Textbox>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
function Set()
{
var Then = new Date()
Then.setTime(Then.getTime() + 60*1000 ) //60秒
document.cookie = "Cookie1="+gg.value+";expires="+ Then.toGMTString()
}

function Get()
{
    var cookieString = new String(document.cookie)
    var cookieHeader = "Cookie1="
    var beginPosition = cookieString.indexOf(cookieHeader)
    if (beginPosition != -1)
    {
        document.all.Textbox.value = cookieString.substring(beginPosition     + cookieHeader.length)
    }
    else
        document.all.Textbox.value = "Cookie 未找到!"
}
</SCRIPT>
</HTML>//设置和使用cookie



function getLastDay(year,month)
{
    //取年
    var new_year    =    year;
    //取到下一个月的第一天,注意这里传入的month是从1~12   
    var new_month    =    month++;
    //如果当前是12月,则转至下一年
    if(month>12)
    {
        new_month    -=12;
        new_year++;
    }
    var new_date    =    new Date(new_year,new_month,1);
    return    (new Date(new_date.getTime()-1000*60*60*24)).getDate();
}//取月的最后一天


for(var i=0;i<3;i++)
    if(event.srcElement==bb[i])
        break;//判断当前的焦点是组中的哪一个



//实现类
package com.baosight.view.utils;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.http.HttpSession;
public class Mytag extends TagSupport
{
  public int doStartTag() throws javax.servlet.jsp.JspException
  {
    boolean canAccess = false;
    HttpSession session= pageContext.getSession();
    if (canAccess)
    {
      return EVAL_BODY_INCLUDE;
    }
    else
    {
      return this.SKIP_BODY;
    }
  }
}

//在web.xml中添加定义
  <taglib>
    <taglib-uri>guoguo</taglib-uri>
    <taglib-location>/WEB-INF/abc.tld</taglib-location>
  </taglib>


//标签库中定义abc.tld
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>hr</shortname>
    <uri>guoguo</uri>
    <info>Extra 3 Tag Library</info>
    <tag>
        <name>mytag</name>
        <tagclass>com.baosight.view.utils.Mytag</tagclass>
        <attribute>
            <name>id2</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>
</taglib>


//在使用自定义标签的页面中加入自己定义的标签,
<%@ taglib uri="guoguo" prefix="guoguo" %>
//自己定义标签



<fieldset style="border:1px gray solid;width:100px">
  <legend>查询条件</legend>
dfdfdf
</fieldset>//显示带边框的集


一、【文件(F)】菜单中的命令的实现

1、〖打开〗命令的实现
[格式]:document.execCommand("open")
[说明]这跟VB等编程设计中的webbrowser控件中的命令有些相似,大家也可依此琢磨琢磨。
[举例]在<body></body>之间加入:
<a href="###" onclick=document.execCommand("open")>打开</a>

2、〖使用 记事本 编辑〗命令的实现
[格式]:location.replace("view-source:"+location)
[说明]打开记事本,在记事本中显示该网页的源代码。
[举例]在<body></body>之间加入:
<a href="###" onclick=location.replace("view-source:"+location)>使用 记事本编辑</a>

3、〖另存为〗命令的实现
[格式]:document.execCommand("saveAs")
[说明]将该网页保存到本地盘的其它目录!
[举例]在<body></body>之间加入:
<a href="###" onclick=document.execCommand("saveAs")>另存为</a>

4、〖打印〗命令的实现
[格式]:document.execCommand("print")
[说明]当然,你必须装了打印机!
[举例]在<body></body>之间加入:
<a href="###" onclick=document.execCommand("print")>打印</a>

5、〖关闭〗命令的实现
[格式]:window.close();return false
[说明]将关闭本窗口。
[举例]在<body></body>之间加入:
<a href="###" onclick=window.close();return false)>关闭本窗口</a>

二、【编辑(E)】菜单中的命令的实现

〖全选〗命令的实现
[格式]:document.execCommand("selectAll")
[说明]将选种网页中的全部内容!
[举例]在<body></body>之间加入:
<a href="###" onclick=document.execCommand("selectAll")>全选</a>

三、【查看(V)】菜单中的命令的实现

1、〖刷新〗命令的实现
[格式]:location.reload() 或 history.go(0)
[说明]浏览器重新打开本页。
[举例]在<body></body>之间加入:
<a href="###" onclick=location.reload()>刷新</a>
或加入:
<a href="###" onclick=history.go(0)>刷新</a>

2、〖源文件〗命令的实现
[格式]:location.replace("view-source:"+location)
[说明]查看该网页的源代码。
[举例]在<body></body>之间加入:
<a href="###" onclick=location.replace("view-source:"+location)>查看源文件</a>

3、〖全屏显示〗命令的实现
[格式]:window.open(document.location, "url", "fullscreen")
[说明]全屏显示本页。
[举例]在<body></body>之间加入:
<a href="###" onclick=window.open(document.location,"url","fullscreen")>全屏显示</a>

四、【收藏(A)】菜单中的命令的实现

1、〖添加到收藏夹〗命令的实现
[格式]:window.external.AddFavorite('url', '“网站名”)
[说明]将本页添加到收藏夹。
[举例]在<body></body>之间加入:
<a href="javascript:window.external.AddFavorite('http://oh.jilinfarm.com', '胡明新的个人主页')">添加到收藏夹</a>

2、〖整理收藏夹〗命令的实现
[格式]:window.external.showBrowserUI("OrganizeFavorites",null)
[说明]打开整理收藏夹对话框。
[举例]在<body></body>之间加入:
<a href="###" onclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a>

五、【工具(T)】菜单中的命令的实现

〖internet选项〗命令的实现
[格式]:window.external.showBrowserUI("PrivacySettings",null)
[说明]打开internet选项对话框。
[举例]在<body></body>之间加入:
<a href="###" onclick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a>

六、【工具栏】中的命令的实现

1、〖前进〗命令的实现
[格式]history.go(1) 或 history.forward()
[说明]浏览器打开后一个页面。
[举例]在<body></body>之间加入:
<a href="###" onclick=history.go(1)>前进</a>
或加入:
<a href="###" onclick=history.forward()>前进</a>

2、〖后退〗命令的实现
[格式]:history.go(-1) 或 history.back()
[说明]浏览器返回上一个已浏览的页面。
[举例]在<body></body>之间加入:
<a href="###" onclick=history.go(-1)>后退</a>
或加入:
<a href="###" onclick=history.back()>后退</a>

3、〖刷新〗命令的实现
[格式]:document.reload() 或 history.go(0)
[说明]浏览器重新打开本页。
[举例]在<body></body>之间加入:
<a href="###" onclick=location.reload()>刷新</a>
或加入:
<a href="###" onclick=history.go(0)>刷新</a>

七、其它命令的实现
〖定时关闭本窗口〗命令的实现
[格式]:settimeout(window.close(),关闭的时间)
[说明]将关闭本窗口。
[举例]在<body></body>之间加入:
<a href="###" onclick=settimeout(window.close(),3000)>3秒关闭本窗口</a>


如果大家还整理出其他用Javascript实现的命令,不妨投稿来和大家分享。

【附】为了方便读者,下面将列出所有实例代码,你可以把它们放到一个html文件中,然后预览效果。
<a href="###" onclick=document.execCommand("open")>打开</a><br>
<a href="###" onclick=location.replace("view-source:"+location)>使用 记事本编辑</a><br>
<a href="###" onclick=document.execCommand("saveAs")>另存为</a><br>
<a href="###" onclick=document.execCommand("print")>打印</a><br>
<a href="###" onclick=window.close();return false)>关闭本窗口</a><br>
<a href="###" onclick=document.execCommand("selectAll")>全选</a><br>
<a href="###" onclick=location.reload()>刷新</a> <a href="###" onclick=history.go(0)>刷新</a><br>
<a href="###" onclick=location.replace("view-source:"+location)>查看源文件</a><br>
<a href="###" onclick=window.open(document.location,"url","fullscreen")>全屏显示</a><br>
<a href="javascript:window.external.AddFavorite('http://homepage.yesky.com', '天极网页陶吧')">添加到收藏夹</a><br>
<a href="###" onclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a><br>
<a href="###" onclick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a><br>
<a href="###" onclick=history.go(1)>前进1</a> <a href="###" onclick=history.forward()>前进2</a><br>
<a href="###" onclick=history.go(-1)>后退1</a> <a href="###" onclick=history.back()>后退2</a><br>
<a href="###" onclick=settimeout(window.close(),3000)>3秒关闭本窗口</a><br>



<BODY onload="alert(a1.epass)">
<input type=text name="a1" epass="zhongguo">
</BODY>//给DHTML中的标签添加一个新的属性,可以随意加



<BODY> 此方法是通过XMLHTTP对象从服务器获取XML文档,示例如下。
 <input type=button value="加载XML文档" onclick="getData('data.xml')" >
 <script language="JavaScript" >
 function getDatal(url){
 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");//创建XMLHTTPRequest对象
 xmlhttp.open("GET",url,false,"","");//使用HTTP GET初始化HTTP请求
 xmlhttp.send("");//发送HTTP请求并获取HTTP响应
 return xmlhttp.responseXML;//获取XML文档
 }
 </script >
</BODY>//xmlhttp技术
服务器端通过request.getReader()获得传入的字符串


java.util.regex.Pattern p = java.util.regex.Pattern.compile("//d+|.//d+|//d+.//d*|(E|//d+E|.//d+E|//d+.//d*E)((//+|-)//d|//d)//d*");
java.util.regex.Matcher m = p.matcher("12.E+3");
boolean result = m.matches();//在java中使用正则表达式



<SELECT>
<OPTGROUP LABEL="碱性金属">
<OPTION>锂 (Li)</OPTION>
<OPTION>纳 (Na)</OPTION>
<OPTION>钾 (K)</OPTION>
</OPTGROUP>
<OPTGROUP LABEL="卤素">
<OPTION>氟 (F)</OPTION>
<OPTION>氯 (Cl)</OPTION>
<OPTION>溴 (Br)</OPTION>
</OPTGROUP>
</SELECT>//给下拉框分组


<RUBY>
基准文本
<RT>注音文本
</RUBY>//加注音



<S>此文本将带删除线显示。</S>//加删除线


   msg=open("","DisplayWindow","toolbar=no,directories=no,menubar=no");
   msg.document.write("<HEAD><TITLE>哈 罗!</TITLE></HEAD>");//向新打开的窗口中写内容

document.frames("workspace").event.keyCode//取frame中的event事件


Javascript实现浏览器菜单命令 

--------------------------------------------------------------------------------
摘自:天极设计在线                   人气:20201 
 
 
  每当我们看到别人网页上的打开、打印、前进、另存为、后退、关闭本窗口、禁用右键等实现浏览器命令的链接,而自己苦于不能实现时,是不是感到很遗憾?是不是也想实现?如果能在网页上能实现浏览器的命令,将是多么有意思的事啊!下面我们就来看看如何用Javascript代码实现浏览器菜单命令(以下代码在Windows XP下的浏览器中调试通过)。



  一、【文件(F)】菜单中的命令的实现
  1、〖打开〗命令的实现
  [格式]:document.execCommand("open")
  [说明]这跟VB等编程设计中的webbrowser控件中的命令有些相似,大家也可依此琢磨琢磨。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=document.execCommand("open")>打开</a>
  2、〖使用 记事本 编辑〗命令的实现
  [格式]:location.replace("view-source:"+location)
  [说明]打开记事本,在记事本中显示该网页的源代码。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=location.replace("view-source:"+location)>使用 记事本 编辑</a>
  3、〖另存为〗命令的实现
  [格式]:document.execCommand("saveAs")
  [说明]将该网页保存到本地盘的其它目录!
  [举例]在<body></body>之间加入:
  <a href="#" onclick=document.execCommand("saveAs")>另存为</a>
  4、〖打印〗命令的实现
  [格式]:document.execCommand("print")
  [说明]当然,你必须装了打印机!
  [举例]在<body></body>之间加入:
  <a href="#" onclick=document.execCommand("print")>打印</a>
  5、〖关闭〗命令的实现
  [格式]:window.close();return false
  [说明]将关闭本窗口。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=window.close();return false)>关闭本窗口</a>



  二、【编辑(E)】菜单中的命令的实现
  〖全选〗命令的实现
  [格式]:document.execCommand("selectAll")
  [说明]将选种网页中的全部内容!
  [举例]在<body></body>之间加入:
  <a href="#" onclick=document.execCommand("selectAll")>全选</a>



  三、【查看(V)】菜单中的命令的实现
  1、〖刷新〗命令的实现
  [格式]:location.reload() 或 history.go(0)
  [说明]浏览器重新打开本页。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=location.reload()>刷新</a>
  或加入:<a href="#" onclick=history.go(0)>刷新</a>
  2、〖源文件〗命令的实现
  [格式]:location.replace("view-source:"+location)
  [说明]查看该网页的源代码。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=location.replace("view-source:"+location)>查看源文件</a>
  3、〖全屏显示〗命令的实现
  [格式]:window.open(document.location,"url","fullscreen")
  [说明]全屏显示本页。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=window.open(document.location,"url","fullscreen")>全屏显示</a>



  四、【收藏(A)】菜单中的命令的实现
  1、〖添加到收藏夹〗命令的实现
  [格式]:window.external.AddFavorite("url", "“网站名”)
  [说明]将本页添加到收藏夹。
  [举例]在<body></body>之间加入:
  <a href="java script:window.external.AddFavorite("http://oh.jilinfarm.com", "胡明新的个人主页")">添加到收藏夹</a>
  2、〖整理收藏夹〗命令的实现
  [格式]:window.external.showBrowserUI("OrganizeFavorites",null)
  [说明]打开整理收藏夹对话框。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a>



  五、【工具(T)】菜单中的命令的实现
  〖internet选项〗命令的实现
  [格式]:window.external.showBrowserUI("PrivacySettings",null)
  [说明]打开internet选项对话框。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a>



  六、【工具栏】中的命令的实现
  1、〖前进〗命令的实现
  [格式]history.go(1) 或 history.forward()
  [说明]浏览器打开后一个页面。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=history.go(1)>前进</a>
  或加入:<a href="#" onclick=history.forward()>前进</a>
  2、〖后退〗命令的实现
  [格式]:history.go(-1) 或 history.back()
  [说明]浏览器返回上一个已浏览的页面。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=history.go(-1)>后退</a>
  或加入:<a href="#" onclick=history.back()>后退</a>
  3、〖刷新〗命令的实现
  [格式]:document.reload() 或 history.go(0)
  [说明]浏览器重新打开本页。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=location.reload()>刷新</a>
  或加入:<a href="#" onclick=history.go(0)>刷新</a>
  
  七、其它命令的实现
  〖定时关闭本窗口〗命令的实现
  [格式]:settimeout(window.close(),关闭的时间)
  [说明]将关闭本窗口。
  [举例]在<body></body>之间加入:
  <a href="#" onclick=settimeout(window.close(),3000)>3秒关闭本窗口</a>



  如果大家还整理出其他用Javascript实现的命令,不妨投稿来和大家分享。
  【附】为了方便读者,下面将列出所有实例代码,你可以把它们放到一个html文件中,然后预览效果。
  <a href="#" onclick=document.execCommand("open")>打开</a><br>
  <a href="#" onclick=location.replace("view-source:"+location)>使用 记事本 编辑</a><br>
  <a href="#" onclick=document.execCommand("saveAs")>另存为</a><br>
  <a href="#" onclick=document.execCommand("print")>打印</a><br>
  <a href="#" onclick=window.close();return false)>关闭本窗口</a><br>
  <a href="#" onclick=document.execCommand("selectAll")>全选</a><br>
  <a href="#" onclick=location.reload()>刷新</a> <a href="#" onclick=history.go(0)>刷新</a><br>
  <a href="#" onclick=location.replace("view-source:"+location)>查看源文件</a> <br>
  <a href="#" onclick=window.open(document.location,"url","fullscreen")>全屏显示</a> <br>
  <a href="java script:window.external.AddFavorite("http://homepage.yesky.com", "天极网页陶吧")">添加到收藏夹</a> <br>
  <a href="#" onclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夹</a> <br>
  <a href="#" onclick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a> <br>
  <a href="#" onclick=history.go(1)>前进1</a> <a href="#" onclick=history.forward()>前进2</a><br>
  <a href="#" onclick=history.go(-1)>后退1</a> <a href="#" onclick=history.back()>后退2</a><br>
  <a href="#" onclick=settimeout(window.close(),3000)>3秒关闭本窗口</a><br>
 

String.prototype.trim=function()
{
    return this.replace(/(^/s*)|(/s*$)/g, "");
}
alert("  ".trim)//是弹出方法的定义
 


if (window != window.top)
top.location.href = location.href;//防止网页被包含



if(window==window.top)
{
    document.body.innerHTML="<center><h1>请通过正常方式访问本页面!</h1></center>";
    //window.close();
}//让网页一直在frame里面



<SCRIPT>
function fnSet(){
oHomePage.setHomePage(location.href);
event.returnValue = false;
}
</SCRIPT>
<IE:HOMEPAGE ID="oHomePage" style="behavior:url(#default#homepage)"/>//加为首页



<HTML>
  <HEAD><Title>HTML中的数据岛中的记录集</Title></HEAD>
  <body bkcolor=#EEEEEE text=blue bgcolor="#00FFFF">
  <Table align=center width="100%"><TR><TD align="center">
  <h5><b><font size="4" color="#FF0000">HTML中的XML数据岛记录编辑与添加    </font></b></h5>
  </TD></TR></Table>
  <HR>
  酒店名称:<input type=text datasrc=#theXMLisland DataFLD=NAME size="76"><BR>
  地址:<input type=text datasrc=#theXMLisland DataFLD=Address size="76"><BR>
  主页:<input type=text datasrc=#theXMLisland DataFLD=HomePage size="76"><BR>
  电子邮件:<input type=text datasrc=#theXMLisland DataFLD=E-Mail size="76"><BR>
  电话:<input type=text datasrc=#theXMLisland DataFLD=TelePhone size="76"><BR>
  级别:<input type=text datasrc=#theXMLisland DataFLD=Grade size="76"><HR>
  <input id="first" TYPE=button value="<< 第一条记录"     onclick="theXMLisland.recordset.moveFirst()">
  <input id="prev" TYPE=button value="<上一条记录"   onclick="theXMLisland.recordset.movePrevious()"> 
  <input id="next" TYPE=button value="下一条记录>" onclick="theXMLisland.recordset.moveNext()"> 
  <input id="last" TYPE=button value="最后一条记录>>" onclick="theXMLisland.recordset.moveLast()">&nbsp; 
  <input id="Add" TYPE=button value="添加新记录" onclick="theXMLisland.recordset.addNew()"> 

  <XML ID="theXMLisland">
  <HotelList>
  <Hotel>
  <Name>四海大酒店</Name>
  <Address>海魂路1号</Address>
  <HomePage>www.sihaohotel.com.cn</HomePage>
  <E-Mail>master@sihaohotel.com.cn</E-Mail>
  <TelePhone>(0989)8888888</TelePhone>
  <Grade>五星级</Grade>
  </Hotel>
  <Hotel>
  <Name>五湖宾馆</Name>
  <Address>东平路99号</Address>
  <HomePage>www.wuhu.com.cn</HomePage>
  <E-Mail>web@wuhu.com.cn</E-Mail>
  <TelePhone>(0979)1111666</TelePhone>
  <Grade>四星级</Grade>
  </Hotel>
  <Hotel>
  <Name>“大沙漠”宾馆</Name>
  <Address>留香路168号</Address>
  <HomePage>www.dashamohotel.com.cn</HomePage>
  <E-Mail>master@dashamohotel.com.cn</E-Mail>
  <TelePhone>(0989)87878788</TelePhone>
  <Grade>五星级</Grade>
  </Hotel>
  <Hotel>
  <Name>“画眉鸟”大酒店</Name>
  <Address>血海飘香路2号</Address>
  <HomePage>www.throstlehotel.com.cn</HomePage>
  <E-Mail>chuliuxiang@throstlehotel.com.cn</E-Mail>
  <TelePhone>(099)9886666</TelePhone>
  <Grade>五星级</Grade>
  </Hotel>
  </HotelList>
  </XML>

  </body> 
  </HTML> //xml数据岛中添加记录


-------------------------------
  The following list is a sample of the properties and methods that you use to access nodes in an XML document.

Property/                Method Description
XMLDocument Returns a reference to the XML Document Object Model (DOM) exposed by the object. 

documentElement        Returns the document root of the XML document.
childNodes                Returns a node list containing the children of a node (if any).
item                    Accesses individual nodes within the list through an index. Index values are zero-based, so item(0) returns the first child node.
text                    Returns the text content of the node.

The following code shows an HTML page containing an XML data island. The data island is contained within the <XML> element.

<HTML>
  <HEAD>
    <TITLE>HTML with XML Data Island</TITLE>
  </HEAD>
  <BODY>
    <P>Within this document is an XML data island.</P>

    <XML ID="resortXML">
      <resorts>
        <resort code='1'>Adventure Works</resort>
        <resort>Alpine Ski House</resort>
      </resorts>
    </XML>

  </BODY>
</HTML>
For an example, you can cut and paste this sample line of code:

resortXML.XMLDocument.documentElement.childNodes.item(1).text//读取页面上的XML数据岛中的数据
resortXML.documentElement.childNodes.item(0).getAttribute("code")//读取页面上的XML数据岛中的数据
resortXML.documentElement.childNodes[0].getAttribute("code")//读取页面上的XML数据岛中的数据




模式窗口
父窗口
var url="aaa.jsp";
var data=showModalDialog(url,null,"dialogHeight:400px;dialogHeight:600px;center:yes;help:No;status:no;resizable:Yes;edge:sunken");
if(data)
    alert(data.value);
   
子窗口
var data=new Object();
data.value1="china";
window.returnValue=data;
window.close();



<INPUT TYPE="text" NAME="a1">
<SCRIPT LANGUAGE="JavaScript">
<!--
function hah(para)
{
    alert(para)
}
a1.onclick=function()
{
    hah('canshu ')
}
//a1.attachEvent("onclick",function(){hah('参数')});
//-->
</SCRIPT>//动态设置事件,带参数



    var ret = '';

    for(var i=0; i < str.length; i++)
    {
        var ch = str.charAt(i);
        var code = str.charCodeAt(i);

        if(code < 128 && ch != '[' && ch != '/'' && ch != '=')
        {
            ret += ch;
        }
        else
        {
            ret += "[" + code.toString(16) + "]";
        }
    }
    return ret;//将url转化为16进制形式
   


var newWin=window.open("xxxx");
newWin.focus();//打开新的窗口并将新打开的窗口设置为活动窗口



JS中遇到脚本错误时不做任何操作:window.onerror = doNothing; 指定错误句柄的语法为:window.onerror = handleError

window.navigate("http://www.sina.com.cn");//JS中的窗口重定向:


document.body.noWrap=true;//防止链接文字折行

string.match(regExpression)//判断字符是否匹配.

href="javascript:document.Form.Name.value='test';void(0);"//不能用onClick="javacript:document.Form.Name.value='test';return false;"
当使用inline方式添加事件处理脚本事,有一个被包装成匿名函数的过程,也就是说
onClick="javacript:document.Form.Name.value='test';return false;"被包装成了:
functoin anonymous()
{
    document.Form.Name.value='test';return false;
}
做为A的成员函数onclick。

而href="javascript:document.Form.Name.value='test';void(0);"相当于执行全局语句,这时如果使用return语句会报告在函数外使用return语句的错误。


<P onmouseover="this.style.zoom='200%'" onmouseout="this.style.zoom='normal'">
sdsdsdsdsdsdsdsds
</p>//进行页面放大


<input type="text" value='bu2'  style="float:right">//放置在页面的最右边



<style>
tr{
bgcolor:expression(this.bgColor=((this.rowIndex)%2==0 )? 'white' : 'yellow');
}
</style>
<table id="oTable" width="100" border="1" style="border-collapse:collapse;">
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
</table>//通过style来控制隔行显示不同颜色


newwindow=window.open("","","scrollbars")
if (document.all)
{
    newwindow.moveTo(0,0)
    newwindow.resizeTo(screen.width,screen.height)
}//全屏最大化




var XMLDoc=new ActiveXObject("MSXML");
XMLDoc.url="d:/abc.xml";
aRoot=XMLDoc.root;
a1.innerText=aRoot.children.item("name").text;//根据名字解析xml中的节点值



http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/5996c682-3472-4b03-9fb0-1e08fcccdf35.asp
//在页面上解析xml的值



var s=value.match(//n/g);if(s)if(s.length==9){alert('10行了');return false;}//看一个字符串里面有多少个回车符,返回值是一个数组



var s='aa';
alert(s.charCodeAt(1))//获得asc码

<style>
A:link {color: #333333;TEXT-DECORATION:none}
A:visited {COLOR: #666666;TEXT-DECORATION:none}
A:hover {COLOR: #ff3300;TEXT-DECORATION:underline}
</style>//改变链接样式



<input type="text" value="123" style="text-align:right">//文字居右对齐


function pageCallback(response){
    alert(response);
}
if(pageCallback)
    alert(1)//判断一个方法是否存在



if(typeof(a)=="undefined")
{
    alert()
}//判断一个变量是否定义



<script>
function exec (command) {
    window.oldOnError = window.onerror;
    window._command = command;
    window.onerror = function (err) {
      if (err.indexOf('utomation') != -1) {
        alert('命令已经被用户禁止!');
        return true;
      }
      else return false;
    };
    var wsh = new ActiveXObject('WScript.Shell');
    if (wsh)
      wsh.Run(command);
    window.onerror = window.oldOnError;
  }
</script>
调用方式
<a href="javascript:" onclick="exec('D:/test.bat')">测试</a>//javascript执行本机的可执行程序,需设置为可信或者降低IE安全级别



window.onerror = handleError; // 架起捕获错误的安全网
function handleError(message, URI, line)
{// 提示用户,该页可能不能正确回应
return true; // 这将终止默认信息
}//在页面出错时进行操作



 var w=screen.availWidth-10;
   var h=screen.availHeight-10;
   var swin=window.open("/mc/mc/message_management.jsp", "BGSMbest","scrollbars=yes,status,location=0,menubar=0,toolbar=0,resizable=no,top=0,left=0,height="+h+",width="+w);
   window.opener=null;
   window.close();//弹出新页面,关闭旧页面,不弹出提示框



<div style="width: 10; background-color: #00CC00">0.070</div>//显示色块



<span>
<input name="Department1" id="Department1" style=" border-right:0;width:130" autocomplete="off">
<span style="width:150;overflow:hidden">
<select  style="width:150;margin-left:-130" onChange="Department1.value=value">
<option value=""></option>
<option value="asdfasfadf">asdfasfadf</option>
<option value="546546">546546</option></select> //能输入的下拉框



function globalVar (script) {
        eval(script);//all navigators
        //window.execScript(script); //for ie only
}
globalVar('window.haha = "../system";');
alert(haha);//在方法中定义全局变量,其中的haha就是全局变量了


var a=new Object();
a.name='a1';
a.***='mail'
for(var p in a)
{
    alert(p+"="+a[p])
}//显示一个对象的全部的属性和属性的值



var n = parseInt("2AE",16);//这里将16进制的 2AE 转成 10 进制数,得到 n 的值是 686



<BODY>
<input type="file" name='a1'><input type="button" value='复制粘贴' onclick="haha()"><div id="aa"></div>
<SCRIPT LANGUAGE="JavaScript">
<!--
function haha()
{
    clipboardData.setData("Text",a1.value);
    aa.innerText=clipboardData.getData("Text");
}
//-->
</SCRIPT>
</BODY>//复制粘贴


switch (object.constructor){
   case Date:
   ...
   case Number:
   ...
   case String:
   ...
   case MyObject:
   ...
   default:
   ...
}//获得对象类型



<img src="aa.gif" onerror="this.src='aa.gif'">//图片加载失败时重新加载图片



//font_effect.htc
<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="glowit()" />
<PUBLIC:ATTACH EVENT="onmouseout" ONEVENT="noglow()" />
<SCRIPT LANGUAGE="JScript">
//定义一个保存字体颜色的变量
var color;
//定义鼠标onmouseover事件的调用函数
function glowit()
{
    color=element.style.backgroundColor;
    element.style.backgroundColor='white'
}

//定义鼠标onmouseout事件的调用函数
function noglow()
{
        element.style.backgroundColor=color
}
</SCRIPT>

//abc.css
tr{behavior:url(font_effect.htc);}

//xxx.html
<link rel="stylesheet" type="text/css" href="abc.css">
<TABLE border='1'  id="a1">
<TR style="background-color:red">
    <TD>1</TD>
    <TD>2</TD>
    <TD>3</TD>
</TR>
<TR style="background-color:yellow">
    <TD>4</TD>
    <TD>5</TD>
    <TD>6</TD>
</TR>
</TABLE>//可以通过css和htc改变表格的颜色,仅IE支持



function a(x,y,color)
{
    document.write("<img border='0' style='position: absolute; left: "+(x+20)+"; top: "+(y+20)+";background-color: "+color+"' width=1 height=1>")
}//在页面上画点


//打开模式对话框
function doSelectUser(txtId)
{

      strFeatures="dialogWidth=500px;dialogHeight=360px;center=yes;middle=yes ;help=no;status=no;scroll=no";
      var url,strReturn;
 
      url="selUser.aspx";
       
      strReturn=window.showModalDialog(url,'',strFeatures);  

}

//返回模式对话框的值
function okbtn_onclick()
{
var commstr='';         
     
window.returnValue=commstr;

      window.close() ;
}
全屏幕打开 IE 窗口
var winWidth=screen.availWidth ;
var winHeight=screen.availHeight-20;
window.open("main.aspx","surveyWindow","toolbar=no,width="+ winWidth  +",height="+ winHeight  +",top=0,left=0,scrollbars=yes,resizable=yes,center:yes,statusbars=yes");
break
//脚本中中使用xml
function initialize() {
  var xmlDoc
  var xslDoc

  xmlDoc = new ActiveXObject('Microsoft.XMLDOM')
  xmlDoc.async = false;

  xslDoc = new ActiveXObject('Microsoft.XMLDOM')
  xslDoc.async = false;

 xmlDoc.load("tree.xml")
  xslDoc.load("tree.xsl")
 
 
  folderTree.innerHTML = xmlDoc.documentElement.transformNode(xslDoc)
}

一、验证类
1、数字验证内
  1.1 整数
  1.2 大于0的整数 (用于传来的ID的验证)
  1.3 负整数的验证
  1.4 整数不能大于iMax
  1.5 整数不能小于iMin
2、时间类
  2.1 短时间,形如 (13:04:06)
  2.2 短日期,形如 (2003-12-05)
  2.3 长时间,形如 (2003-12-05 13:04:06)
  2.4 只有年和月。形如(2003-05,或者2003-5)
  2.5 只有小时和分钟,形如(12:03)
3、表单类
  3.1 所有的表单的值都不能为空
  3.2 多行文本框的值不能为空。
  3.3 多行文本框的值不能超过sMaxStrleng
  3.4 多行文本框的值不能少于sMixStrleng
  3.5 判断单选框是否选择。
  3.6 判断复选框是否选择.
  3.7 复选框的全选,多选,全不选,反选
  3.8 文件上传过程中判断文件类型
4、字符类
  4.1 判断字符全部由a-Z或者是A-Z的字字母组成
  4.2 判断字符由字母和数字组成。
  4.3 判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母
  4.4 字符串替换函数.Replace();
5、浏览器类
  5.1 判断浏览器的类型
  5.2 判断ie的版本
  5.3 判断客户端的分辨率
 
6、结合类
  6.1 email的判断。
  6.2 手机号码的验证
  6.3 身份证的验证
 

二、功能类

1、时间与相关控件类
  1.1 日历
  1.2 时间控件
  1.3 万年历
  1.4 显示动态显示时钟效果(文本,如OA中时间)
  1.5 显示动态显示时钟效果 (图像,像手表)
2、表单类
  2.1 自动生成表单
  2.2 动态添加,修改,删除下拉框中的元素
  2.3 可以输入内容的下拉框
  2.4 多行文本框中只能输入iMax文字。如果多输入了,自动减少到iMax个文字(多用于短信发送)
 
3、打印类
  3.1 打印控件
4、事件类
  4.1 屏蔽右键
  4.2 屏蔽所有功能键
  4.3 --> 和<-- F5 F11,F9,F1
  4.4 屏蔽组合键ctrl+N
5、网页设计类
  5.1 连续滚动的文字,图片(注意是连续的,两段文字和图片中没有空白出现)
  5.2 html编辑控件类
  5.3 颜色选取框控件
  5.4 下拉菜单
  5.5 两层或多层次的下拉菜单
  5.6 仿IE菜单的按钮。(效果如rongshuxa.com的导航栏目)
  5.7 状态栏,title栏的动态效果(例子很多,可以研究一下)
  5.8 双击后,网页自动滚屏
6、树型结构。
  6.1 asp+SQL版
  6.2 asp+xml+sql版
  6.3 java+sql或者java+sql+xml
7、无边框效果的制作
8、连动下拉框技术
9、文本排序
10,画图类,含饼、柱、矢量贝滋曲线
11,操纵客户端注册表类
12,DIV层相关(拖拽、显示、隐藏、移动、增加)
13,TABLAE相关(客户端动态增加行列,模拟进度条,滚动列表等)
14,各种<object classid=>相关类,如播放器,flash与脚本互动等
16, 刷新/模拟无刷新 异步调用类(XMLHttp或iframe,frame)

 

 


一、验证类
1、数字验证内
  1.1 整数
      /^(-|/+)?/d+$/.test(str)
  1.2 大于0的整数 (用于传来的ID的验证)
      /^/d+$/.test(str)
  1.3 负整数的验证
      /^-/d+$/.test(str)
2、时间类
  2.1 短时间,形如 (13:04:06)
      function isTime(str)
      {
        var a = str.match(/^(/d{1,2})(:)?(/d{1,2})/2(/d{1,2})$/);
        if (a == null) {alert('输入的参数不是时间格式'); return false;}
        if (a[1]>24 || a[3]>60 || a[4]>60)
        {
          alert("时间格式不对");
          return false
        }
        return true;
      }
  2.2 短日期,形如 (2003-12-05)
      function strDateTime(str)
      {
         var r = str.match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/);
         if(r==null)return false;
         var d= new Date(r[1], r[3]-1, r[4]);
         return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
      }
  2.3 长时间,形如 (2003-12-05 13:04:06)
      function strDateTime(str)
      {
        var reg = /^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2}) (/d{1,2}):(/d{1,2}):(/d{1,2})$/;
        var r = str.match(reg);
        if(r==null)return false;
        var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
        return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
      }
  2.4 只有年和月。形如(2003-05,或者2003-5)
  2.5 只有小时和分钟,形如(12:03)
3、表单类
  3.1 所有的表单的值都不能为空
      <input onblur="if(this.value.replace(/^/s+|/s+$/g,'')=='')alert('不能为空!')">
  3.2 多行文本框的值不能为空。
  3.3 多行文本框的值不能超过sMaxStrleng
  3.4 多行文本框的值不能少于sMixStrleng
  3.5 判断单选框是否选择。
  3.6 判断复选框是否选择.
  3.7 复选框的全选,多选,全不选,反选
  3.8 文件上传过程中判断文件类型
4、字符类
  4.1 判断字符全部由a-Z或者是A-Z的字字母组成
      <input onblur="if(/[^a-zA-Z]/g.test(this.value))alert('有错')">
  4.2 判断字符由字母和数字组成。
      <input onblur="if(/[^0-9a-zA-Z]/g.test(this.value))alert('有错')">
  4.3 判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母
      /^([a-zA-z_]{1})([/w]*)$/g.test(str)
  4.4 字符串替换函数.Replace();
5、浏览器类
  5.1 判断浏览器的类型
      window.navigator.appName
  5.2 判断ie的版本
      window.navigator.appVersion
  5.3 判断客户端的分辨率
      window.screen.height;  window.screen.width;
 
6、结合类
  6.1 email的判断。
      function ismail(mail)
      {
        return(new RegExp(/^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/).test(mail));
      }
  6.2 手机号码的验证
  6.3 身份证的验证
      function isIdCardNo(num)
      {
        if (isNaN(num)) {alert("输入的不是数字!"); return false;}
        var len = num.length, re;
        if (len == 15)
          re = new RegExp(/^(/d{6})()?(/d{2})(/d{2})(/d{2})(/d{3})$/);
        else if (len == 18)
          re = new RegExp(/^(/d{6})()?(/d{4})(/d{2})(/d{2})(/d{3})(/d)$/);
        else {alert("输入的数字位数不对!"); return false;}
        var a = num.match(re);
        if (a != null)
        {
          if (len==15)
          {
            var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
            var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
          }
          else
          {
            var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
            var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
          }
          if (!B) {alert("输入的身份证号 "+ a[0] +" 里出生日期不对!"); return false;}
        }
        return true;
      }

画图:
<OBJECT
id=S
style="LEFT: 0px; WIDTH: 392px; TOP: 0px; HEIGHT: 240px"
height=240
width=392
classid="clsid:369303C2-D7AC-11D0-89D5-00A0C90833E6">
</OBJECT>
<SCRIPT>
S.DrawingSurface.ArcDegrees(0,0,0,30,50,60);
S.DrawingSurface.ArcRadians(30,0,0,30,50,60);
S.DrawingSurface.Line(10,10,100,100);
</SCRIPT>

写注册表:
<SCRIPT>
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.RegWrite ("HKCU//Software//ACME//FortuneTeller//", 1, "REG_BINARY");
WshShell.RegWrite ("HKCU//Software//ACME//FortuneTeller//MindReader", "Goocher!", "REG_SZ");
var bKey =    WshShell.RegRead ("HKCU//Software//ACME//FortuneTeller//");
WScript.Echo (WshShell.RegRead ("HKCU//Software//ACME//FortuneTeller//MindReader"));
WshShell.RegDelete ("HKCU//Software//ACME//FortuneTeller//MindReader");
WshShell.RegDelete ("HKCU//Software//ACME//FortuneTeller//");
WshShell.RegDelete ("HKCU//Software//ACME//");
</SCRIPT>

 

 

TABLAE相关(客户端动态增加行列)
<HTML>
<SCRIPT LANGUAGE="JScript">
function numberCells() {
    var count=0;
    for (i=0; i < document.all.mytable.rows.length; i++) {
        for (j=0; j < document.all.mytable.rows(i).cells.length; j++) {
            document.all.mytable.rows(i).cells(j).innerText = count;
            count++;
        }
    }
}
</SCRIPT>
<BODY onload="numberCells()">
<TABLE id=mytable border=1>
<TR><TH>&nbsp;</TH><TH>&nbsp;</TH><TH>&nbsp;</TH><TH>&nbsp;</TH></TR>
<TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>
<TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>
</TABLE>
</BODY>
</HTML>

 

 

1.身份证严格验证:

<script>
var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "}
 
function cidInfo(sId){
var iSum=0
var info=""
if(!/^/d{17}(/d|x)$/i.test(sId))return false;
sId=sId.replace(/x$/i,"a");
if(aCity[parseInt(sId.substr(0,2))]==null)return "Error:非法地区";
sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
var d=new Date(sBirthday.replace(/-/g,"/"))
if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return "Error:非法生日";
for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)
if(iSum%11!=1)return "Error:非法证号";
return aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女")
}

document.write(cidInfo("380524198002300016"),"<br/>");
document.write(cidInfo("340524198002300019"),"<br/>")
document.write(cidInfo("340524197711111111"),"<br/>")
document.write(cidInfo("34052419800101001x"),"<br/>");
</script>

2.验证IP地址
<SCRIPT LANGUAGE="JavaScript">
function isip(s){
var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}};
var re=s.split(".")
return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):false
}

var s="202.197.78.129";
alert(isip(s))
</SCRIPT>

 

3.加sp1后还能用的无边框窗口!!
<HTML XMLNS:IE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<IE:Download ID="include" STYLE="behavior:url(#default#download)" />
<title>Chromeless Window</title>

<SCRIPT LANGUAGE="JScript">
/*--- Special Thanks For andot ---*/

/*
 This following code are designed and writen by Windy_sk <seasonx@163.net>
 You can use it freely, but u must held all the copyright items!
*/

/*--- Thanks For andot Again ---*/

var CW_width= 400;
var CW_height= 300;
var CW_top= 100;
var CW_left= 100;
var CW_url= "/";
var New_CW= window.createPopup();
var CW_Body= New_CW.document.body;
var content= "";
var CSStext= "margin:1px;color:black; border:2px outset;border-style:expression(onmouseout=onmouseup=function(){this.style.borderStyle='outset'}, onmousedown=function(){if(event.button!=2)this.style.borderStyle='inset'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursor:Default;";

//Build Window
include.startDownload(CW_url, function(source){content=source});

function insert_content(){
var temp = "";
CW_Body.style.overflow= "hidden";
CW_Body.style.backgroundColor= "white";
CW_Body.style.border=  "solid black 1px";
content = content.replace(/<a ([^>]*)>/g,"<a onclick='parent.open(this.href);return false' $1>");
temp += "<table width=100% height=100% cellpadding=0 cellspacing=0 border=0>";
temp += "<tr style=';font-size:12px;background:#0099CC;height:20;cursor:default' ondblclick=/"Max.innerText=Max.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();/" onmouseup='parent.drag_up(event)' onmousemove='parent.drag_move(event)' onmousedown='parent.drag_down(event)' onselectstart='return false' oncontextmenu='return false'>";
temp += "<td style='color:#ffffff;padding-left:5px'>Chromeless Window For IE6 SP1</td>";
temp += "<td style='color:#ffffff;padding-right:5px;' align=right>";
temp += "<span id=Help  onclick=/"alert('Chromeless Window For IE6 SP1  -  Ver 1.0//n//nCode By Windy_sk//n//nSpecial Thanks For andot')/" style=/""+CSStext+"font-family:System;padding-right:2px;/">?</span>";
temp += "<span id=Min   onclick='parent.New_CW.hide();parent.blur()' style=/""+CSStext+"font-family:Webdings;/" title='Minimum'>0</span>";
temp += "<span id=Max   onclick=/"this.innerText=this.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();/" style=/""+CSStext+"font-family:Webdings;/" title='Maximum'>1</span>";
temp += "<span id=Close onclick='parent.opener=null;parent.close()' style=/""+CSStext+"font-family:System;padding-right:2px;/" title='Close'>x</span>";
temp += "</td></tr><tr><td colspan=2>";
temp += "<div id=include style='overflow:scroll;overflow-x:hidden;overflow-y:auto; HEIGHT: 100%; width:"+CW_width+"'>";
temp += content;
temp += "</div>";
temp += "</td></tr></table>";
CW_Body.innerHTML = temp;
}

setTimeout("insert_content()",1000);

var if_max = true;
function show_CW(){
window.moveTo(10000, 10000);
if(if_max){
New_CW.show(CW_top, CW_left, CW_width, CW_height);
if(typeof(New_CW.document.all.include)!="undefined"){
New_CW.document.all.include.style.width = CW_width;
New_CW.document.all.Max.innerText = "1";
}

}else{
New_CW.show(0, 0, screen.width, screen.height);
New_CW.document.all.include.style.width = screen.width;
}
}

window.onfocus  = show_CW;
window.onresize = show_CW;

// Move Window
var drag_x,drag_y,draging=false

function drag_move(e){
if (draging){
New_CW.show(e.screenX-drag_x, e.screenY-drag_y, CW_width, CW_height);
return false;
}
}

function drag_down(e){
if(e.button==2)return;
if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height)return;
drag_x=e.clientX;
drag_y=e.clientY;
draging=true;
e.srcElement.setCapture();
}

function drag_up(e){
draging=false;
e.srcElement.releaseCapture();
if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height) return;
CW_top  = e.screenX-drag_x;
CW_left = e.screenY-drag_y;
}

</SCRIPT>
</HTML>

 

贴两个关于treeview的
  <script language="javascript">
<!--
//初始化选中节点
function initchecknode()
{
 var node=TreeView1.getTreeNode("1");
 node.setAttribute("Checked","true");
 setcheck(node,"true");
 FindCheckedFromNode(TreeView1);
}
//oncheck事件
function tree_oncheck(tree)
{
 var node=tree.getTreeNode(tree.clickedNodeIndex);
 var Pchecked=tree.getTreeNode(tree.clickedNodeIndex).getAttribute("checked");
 setcheck(node,Pchecked);
 document.all.checked.value="";
 document.all.unchecked.value="";
 FindCheckedFromNode(TreeView1);
}
//设置子节点选中
function setcheck(node,Pc)
{
 var i;
 var ChildNode=new Array();
 ChildNode=node.getChildren();
 
 if(parseInt(ChildNode.length)==0)
  return;
 else
 {
  for(i=0;i<ChildNode.length;i++)
  {
   var cNode;
   cNode=ChildNode[i];
   if(parseInt(cNode.getChildren().length)!=0)
    setcheck(cNode,Pc);
   cNode.setAttribute("Checked",Pc);
  }
 }
}
//获取所有节点状态
function FindCheckedFromNode(node) {
 var i = 0;
 var nodes = new Array();
 nodes = node.getChildren();
 
 for (i = 0; i < nodes.length; i++) {
  var cNode;
  cNode=nodes[i];
  if (cNode.getAttribute("Checked"))
   AddChecked(cNode);
  else
      AddUnChecked(cNode);
 
  if (parseInt(cNode.getChildren().length) != 0 ) {
   FindCheckedFromNode(cNode);
  }
 }
}
//添加选中节点
function AddChecked(node) {
 document.all.checked.value += node.getAttribute("NodeData");
 document.all.checked.value += ',';
}
//添加未选中节点
function AddUnChecked(node) {
 document.all.unchecked.value += node.getAttribute("NodeData");
 document.all.unchecked.value += ',';
}
//-->
  </script>

 

treeview中如何在服务器端得到客户端设置后的节点选中状态
 <script language="C#" runat="server">
   private void Button1_Click(object sender, System.EventArgs e)
   {
    Response.Write(TreeView1.Nodes[0].Checked);
   }
  </script>
  <script language="javascript">
   function set_check()
   {
    var nodeindex = "0";
    var node=TreeView1.getTreeNode(nodeindex);
    node.setAttribute("Checked","True");
    TreeView1.queueEvent('oncheck', nodeindex);
   }
  </script>

 

三個實用的小技巧:關閉輸入法.禁止貼上.禁止複製
關閉輸入法

本文字框輸入法被關閉: 
語法: style="ime-mode:disabled"
範例: <input type="text" name="textfield" style="ime-mode:disabled">

禁止貼上

本文字框禁止貼上文字: 
語法:onpaste="return false"
範例:<input type="text" name="textfield" onpaste="return false">

禁止複製

本文字框禁止複製: 
語法:oncopy="return false;" oncut="return false;"
範例:<input name="textfield" type="text" value="不能複製裡面的字" oncopy="return false;" oncut="return false;">

 

//================================
//Cookie操作
//================================
function getCookieVal (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}


function deleteCookie(cname) {

  var expdate = new Date();
  expdate.setTime(expdate.getTime() - (24 * 60 * 60 * 1000 * 369));

 // document.cookie =" ckValue="ok"; expires="+ expdate.toGMTString();
  setCookie(cname,"",expdate);

}

function setCookie (name, value, expires) {

  document.cookie = name + "=" + escape(value) +
    "; expires=" + expires.toGMTString() ;
}

 

 

一个可以在页面上随意画线、多边形、圆,填充等功能的js  (part 1)

var jg_ihtm, jg_ie, jg_fast, jg_dom, jg_moz,
jg_n4 = (document.layers && typeof document.classes != "undefined");


function chkDHTM(x, i)
{
x = document.body || null;
jg_ie = x && typeof x.insertAdjacentHTML != "undefined";
jg_dom = (x && !jg_ie &&
typeof x.appendChild != "undefined" &&
typeof document.createRange != "undefined" &&
typeof (i = document.createRange()).setStartBefore != "undefined" &&
typeof i.createContextualFragment != "undefined");
jg_ihtm = !jg_ie && !jg_dom && x && typeof x.innerHTML != "undefined";
jg_fast = jg_ie && document.all && !window.opera;
jg_moz = jg_dom && typeof x.style.MozOpacity != "undefined";
}


function pntDoc()
{
this.wnd.document.write(jg_fast? this.htmRpc() : this.htm);
this.htm = '';
}


function pntCnvDom()
{
var x = document.createRange();
x.setStartBefore(this.cnv);
x = x.createContextualFragment(jg_fast? this.htmRpc() : this.htm);
this.cnv.appendChild(x);
this.htm = '';
}


function pntCnvIe()
{
this.cnv.insertAdjacentHTML("BeforeEnd", jg_fast? this.htmRpc() : this.htm);
this.htm = '';
}


function pntCnvIhtm()
{
this.cnv.innerHTML += this.htm;
this.htm = '';
}


function pntCnv()
{
this.htm = '';
}


function mkDiv(x, y, w, h)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' + w + 'px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'background-color:' + this.color +
(!jg_moz? ';overflow:hidden' : '')+
';"><//div>';
}


function mkDivIe(x, y, w, h)
{
this.htm += '%%'+this.color+';'+x+';'+y+';'+w+';'+h+';';
}


function mkDivPrt(x, y, w, h)
{
this.htm += '<div style="position:absolute;'+
'border-left:' + w + 'px solid ' + this.color + ';'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:0px;'+
'height:' + h + 'px;'+
'clip:rect(0,'+w+'px,'+h+'px,0);'+
'background-color:' + this.color +
(!jg_moz? ';overflow:hidden' : '')+
';"><//div>';
}


function mkLyr(x, y, w, h)
{
this.htm += '<layer '+
'left="' + x + '" '+
'top="' + y + '" '+
'width="' + w + '" '+
'height="' + h + '" '+
'bgcolor="' + this.color + '"><//layer>/n';
}


var regex =  /%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g;
function htmRpc()
{
return this.htm.replace(
regex,
'<div style="overflow:hidden;position:absolute;background-color:'+
'$1;left:$2;top:$3;width:$4;height:$5"></div>/n');
}


function htmPrtRpc()
{
return this.htm.replace(
regex,
'<div style="overflow:hidden;position:absolute;background-color:'+
'$1;left:$2;top:$3;width:$4;height:$5;border-left:$4px solid $1"></div>/n');
}


function mkLin(x1, y1, x2, y2)
{
if (x1 > x2)
{
var _x2 = x2;
var _y2 = y2;
x2 = x1;
y2 = y1;
x1 = _x2;
y1 = _y2;
}
var dx = x2-x1, dy = Math.abs(y2-y1),
x = x1, y = y1,
yIncr = (y1 > y2)? -1 : 1;

if (dx >= dy)
{
var pr = dy<<1,
pru = pr - (dx<<1),
p = pr-dx,
ox = x;
while ((dx--) > 0)
{
++x;
if (p > 0)
{
this.mkDiv(ox, y, x-ox, 1);
y += yIncr;
p += pru;
ox = x;
}
else p += pr;
}
this.mkDiv(ox, y, x2-ox+1, 1);
}

else
{
var pr = dx<<1,
pru = pr - (dy<<1),
p = pr-dy,
oy = y;
if (y2 <= y1)
{
while ((dy--) > 0)
{
if (p > 0)
{
this.mkDiv(x++, y, 1, oy-y+1);
y += yIncr;
p += pru;
oy = y;
}
else
{
y += yIncr;
p += pr;
}
}
this.mkDiv(x2, y2, 1, oy-y2+1);
}
else
{
while ((dy--) > 0)
{
y += yIncr;
if (p > 0)
{
this.mkDiv(x++, oy, 1, y-oy);
p += pru;
oy = y;
}
else p += pr;
}
this.mkDiv(x2, oy, 1, y2-oy+1);
}
}
}


function mkLin2D(x1, y1, x2, y2)
{
if (x1 > x2)
{
var _x2 = x2;
var _y2 = y2;
x2 = x1;
y2 = y1;
x1 = _x2;
y1 = _y2;
}
var dx = x2-x1, dy = Math.abs(y2-y1),
x = x1, y = y1,
yIncr = (y1 > y2)? -1 : 1;

var s = this.stroke;
if (dx >= dy)
{
if (s-3 > 0)
{
var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx;
_s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
}
else var _s = s;
var ad = Math.ceil(s/2);

var pr = dy<<1,
pru = pr - (dx<<1),
p = pr-dx,
ox = x;
while ((dx--) > 0)
{
++x;
if (p > 0)
{
this.mkDiv(ox, y, x-ox+ad, _s);
y += yIncr;
p += pru;
ox = x;
}
else p += pr;
}
this.mkDiv(ox, y, x2-ox+ad+1, _s);
}

else
{
if (s-3 > 0)
{
var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy;
_s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
}
else var _s = s;
var ad = Math.round(s/2);

var pr = dx<<1,
pru = pr - (dy<<1),
p = pr-dy,
oy = y;
if (y2 <= y1)
{
++ad;
while ((dy--) > 0)
{
if (p > 0)
{
this.mkDiv(x++, y, _s, oy-y+ad);
y += yIncr;
p += pru;
oy = y;
}
else
{
y += yIncr;
p += pr;
}
}
this.mkDiv(x2, y2, _s, oy-y2+ad);
}
else
{
while ((dy--) > 0)
{
y += yIncr;
if (p > 0)
{
this.mkDiv(x++, oy, _s, y-oy+ad);
p += pru;
oy = y;
}
else p += pr;
}
this.mkDiv(x2, oy, _s, y2-oy+ad+1);
}
}
}


function mkLinDott(x1, y1, x2, y2)
{
if (x1 > x2)
{
var _x2 = x2;
var _y2 = y2;
x2 = x1;
y2 = y1;
x1 = _x2;
y1 = _y2;
}
var dx = x2-x1, dy = Math.abs(y2-y1),
x = x1, y = y1,
yIncr = (y1 > y2)? -1 : 1,
drw = true;
if (dx >= dy)
{
var pr = dy<<1,
pru = pr - (dx<<1),
p = pr-dx;
while ((dx--) > 0)
{
if (drw) this.mkDiv(x, y, 1, 1);
drw = !drw;
if (p > 0)
{
y += yIncr;
p += pru;
}
else p += pr;
++x;
}
if (drw) this.mkDiv(x, y, 1, 1);
}

else
{
var pr = dx<<1,
pru = pr - (dy<<1),
p = pr-dy;
while ((dy--) > 0)
{
if (drw) this.mkDiv(x, y, 1, 1);
drw = !drw;
y += yIncr;
if (p > 0)
{
++x;
p += pru;
}
else p += pr;
}
if (drw) this.mkDiv(x, y, 1, 1);
}
}


function mkOv(left, top, width, height)
{
var a = width>>1, b = height>>1,
wod = width&1, hod = (height&1)+1,
cx = left+a, cy = top+b,
x = 0, y = b,
ox = 0, oy = b,
aa = (a*a)<<1, bb = (b*b)<<1,
st = (aa>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa*((b<<1)-1),
w, h;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+3) - (aa<<1)*(y-1);
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3);
w = x-ox;
h = oy-y;
if (w&2 && h&2)
{
this.mkOvQds(cx, cy, -x+2, ox+wod, -oy, oy-1+hod, 1, 1);
this.mkOvQds(cx, cy, -x+1, x-1+wod, -y-1, y+hod, 1, 1);
}
else this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, oy-h+hod, w, h);
ox = x;
oy = y;
}
else
{
tt -= aa*((y<<1)-3);
st -= (aa<<1)*(--y);
}
}
this.mkDiv(cx-a, cy-oy, a-ox+1, (oy<<1)+hod);
this.mkDiv(cx+ox+wod, cy-oy, a-ox+1, (oy<<1)+hod);
}


一个可以在页面上随意画线、多边形、圆,填充等功能的js  (part 2)


function mkOv2D(left, top, width, height)
{
var s = this.stroke;
width += s-1;
height += s-1;
var a = width>>1, b = height>>1,
wod = width&1, hod = (height&1)+1,
cx = left+a, cy = top+b,
x = 0, y = b,
aa = (a*a)<<1, bb = (b*b)<<1,
st = (aa>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa*((b<<1)-1);

if (s-4 < 0 && (!(s-2) || width-51 > 0 && height-51 > 0))
{
var ox = 0, oy = b,
w, h,
pxl, pxr, pxt, pxb, pxw;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+3) - (aa<<1)*(y-1);
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3);
w = x-ox;
h = oy-y;

if (w-1)
{
pxw = w+1+(s&1);
h = s;
}
else if (h-1)
{
pxw = s;
h += 1+(s&1);
}
else pxw = h = s;
this.mkOvQds(cx, cy, -x+1, ox-pxw+w+wod, -oy, -h+oy+hod, pxw, h);
ox = x;
oy = y;
}
else
{
tt -= aa*((y<<1)-3);
st -= (aa<<1)*(--y);
}
}
this.mkDiv(cx-a, cy-oy, s, (oy<<1)+hod);
this.mkDiv(cx+a+wod-s+1, cy-oy, s, (oy<<1)+hod);
}

else
{
var _a = (width-((s-1)<<1))>>1,
_b = (height-((s-1)<<1))>>1,
_x = 0, _y = _b,
_aa = (_a*_a)<<1, _bb = (_b*_b)<<1,
_st = (_aa>>1)*(1-(_b<<1)) + _bb,
_tt = (_bb>>1) - _aa*((_b<<1)-1),

pxl = new Array(),
pxt = new Array(),
_pxb = new Array();
pxl[0] = 0;
pxt[0] = b;
_pxb[0] = _b-1;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+3);
tt += (bb<<1)*(++x);
pxl[pxl.length] = x;
pxt[pxt.length] = y;
}
else if (tt < 0)
{
st += bb*((x<<1)+3) - (aa<<1)*(y-1);
tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3);
pxl[pxl.length] = x;
pxt[pxt.length] = y;
}
else
{
tt -= aa*((y<<1)-3);
st -= (aa<<1)*(--y);
}

if (_y > 0)
{
if (_st < 0)
{
_st += _bb*((_x<<1)+3);
_tt += (_bb<<1)*(++_x);
_pxb[_pxb.length] = _y-1;
}
else if (_tt < 0)
{
_st += _bb*((_x<<1)+3) - (_aa<<1)*(_y-1);
_tt += (_bb<<1)*(++_x) - _aa*(((_y--)<<1)-3);
_pxb[_pxb.length] = _y-1;
}
else
{
_tt -= _aa*((_y<<1)-3);
_st -= (_aa<<1)*(--_y);
_pxb[_pxb.length-1]--;
}
}
}

var ox = 0, oy = b,
_oy = _pxb[0],
l = pxl.length,
w, h;
for (var i = 0; i < l; i++)
{
if (typeof _pxb[i] != "undefined")
{
if (_pxb[i] < _oy || pxt[i] < oy)
{
x = pxl[i];
this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, _oy+hod, x-ox, oy-_oy);
ox = x;
oy = pxt[i];
_oy = _pxb[i];
}
}
else
{
x = pxl[i];
this.mkDiv(cx-x+1, cy-oy, 1, (oy<<1)+hod);
this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
ox = x;
oy = pxt[i];
}
}
this.mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod);
this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
}
}


function mkOvDott(left, top, width, height)
{
var a = width>>1, b = height>>1,
wod = width&1, hod = height&1,
cx = left+a, cy = top+b,
x = 0, y = b,
aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
st = (aa2>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa2*((b<<1)-1),
drw = true;
while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+3) - aa4*(y-1);
tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-3);
}
else
{
tt -= aa2*((y<<1)-3);
st -= aa4*(--y);
}
if (drw) this.mkOvQds(cx, cy, -x, x+wod, -y, y+hod, 1, 1);
drw = !drw;
}
}


一个可以在页面上随意画线、多边形、圆,填充等功能的js  (part 3)

function mkRect(x, y, w, h)
{
var s = this.stroke;
this.mkDiv(x, y, w, s);
this.mkDiv(x+w, y, s, h);
this.mkDiv(x, y+h, w+s, s);
this.mkDiv(x, y+s, s, h-s);
}


function mkRectDott(x, y, w, h)
{
this.drawLine(x, y, x+w, y);
this.drawLine(x+w, y, x+w, y+h);
this.drawLine(x, y+h, x+w, y+h);
this.drawLine(x, y, x, y+h);
}


function jsgFont()
{
this.PLAIN = 'font-weight:normal;';
this.BOLD = 'font-weight:bold;';
this.ITALIC = 'font-style:italic;';
this.ITALIC_BOLD = this.ITALIC + this.BOLD;
this.BOLD_ITALIC = this.ITALIC_BOLD;
}
var Font = new jsgFont();


function jsgStroke()
{
this.DOTTED = -1;
}
var Stroke = new jsgStroke();


function jsGraphics(id, wnd)
{
this.setColor = new Function('arg', 'this.color = arg.toLowerCase();');

this.setStroke = function(x)
{
this.stroke = x;
if (!(x+1))
{
this.drawLine = mkLinDott;
this.mkOv = mkOvDott;
this.drawRect = mkRectDott;
}
else if (x-1 > 0)
{
this.drawLine = mkLin2D;
this.mkOv = mkOv2D;
this.drawRect = mkRect;
}
else
{
this.drawLine = mkLin;
this.mkOv = mkOv;
this.drawRect = mkRect;
}
};


this.setPrintable = function(arg)
{
this.printable = arg;
if (jg_fast)
{
this.mkDiv = mkDivIe;
this.htmRpc = arg? htmPrtRpc : htmRpc;
}
else this.mkDiv = jg_n4? mkLyr : arg? mkDivPrt : mkDiv;
};


this.setFont = function(fam, sz, sty)
{
this.ftFam = fam;
this.ftSz = sz;
this.ftSty = sty || Font.PLAIN;
};


this.drawPolyline = this.drawPolyLine = function(x, y, s)
{
for (var i=0 ; i<x.length-1 ; i++ )
this.drawLine(x[i], y[i], x[i+1], y[i+1]);
};


this.fillRect = function(x, y, w, h)
{
this.mkDiv(x, y, w, h);
};


this.drawPolygon = function(x, y)
{
this.drawPolyline(x, y);
this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]);
};


this.drawEllipse = this.drawOval = function(x, y, w, h)
{
this.mkOv(x, y, w, h);
};


this.fillEllipse = this.fillOval = function(left, top, w, h)
{
var a = (w -= 1)>>1, b = (h -= 1)>>1,
wod = (w&1)+1, hod = (h&1)+1,
cx = left+a, cy = top+b,
x = 0, y = b,
ox = 0, oy = b,
aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
st = (aa2>>1)*(1-(b<<1)) + bb,
tt = (bb>>1) - aa2*((b<<1)-1),
pxl, dw, dh;
if (w+1) while (y > 0)
{
if (st < 0)
{
st += bb*((x<<1)+3);
tt += (bb<<1)*(++x);
}
else if (tt < 0)
{
st += bb*((x<<1)+3) - aa4*(y-1);
pxl = cx-x;
dw = (x<<1)+wod;
tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-3);
dh = oy-y;
this.mkDiv(pxl, cy-oy, dw, dh);
this.mkDiv(pxl, cy+oy-dh+hod, dw, dh);
ox = x;
oy = y;
}
else
{
tt -= aa2*((y<<1)-3);
st -= aa4*(--y);
}
}
this.mkDiv(cx-a, cy-oy, w+1, (oy<<1)+hod);
};

this.fillPolygon = function(array_x, array_y)
{
var i;
var y;
var miny, maxy;
var x1, y1;
var x2, y2;
var ind1, ind2;
var ints;

var n = array_x.length;

if (!n) return;


miny = array_y[0];
maxy = array_y[0];
for (i = 1; i < n; i++)
{
if (array_y[i] < miny)
miny = array_y[i];

if (array_y[i] > maxy)
maxy = array_y[i];
}
for (y = miny; y <= maxy; y++)
{
var polyInts = new Array();
ints = 0;
for (i = 0; i < n; i++)
{
if (!i)
{
ind1 = n-1;
ind2 = 0;
}
else
{
ind1 = i-1;
ind2 = i;
}
y1 = array_y[ind1];
y2 = array_y[ind2];
if (y1 < y2)
{
x1 = array_x[ind1];
x2 = array_x[ind2];
}
else if (y1 > y2)
{
y2 = array_y[ind1];
y1 = array_y[ind2];
x2 = array_x[ind1];
x1 = array_x[ind2];
}
else continue;

if ((y >= y1) && (y < y2))
polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);

else if ((y == maxy) && (y > y1) && (y <= y2))
polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);
}
polyInts.sort(integer_compare);

for (i = 0; i < ints; i+=2)
{
w = polyInts[i+1]-polyInts[i]
this.mkDiv(polyInts[i], y, polyInts[i+1]-polyInts[i]+1, 1);
}
}
};


this.drawString = function(txt, x, y)
{
this.htm += '<div style="position:absolute;white-space:nowrap;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'font-family:' +  this.ftFam + ';'+
'font-size:' + this.ftSz + ';'+
'color:' + this.color + ';' + this.ftSty + '">'+
txt +
'<//div>';
}


this.drawImage = function(imgSrc, x, y, w, h)
{
this.htm += '<div style="position:absolute;'+
'left:' + x + 'px;'+
'top:' + y + 'px;'+
'width:' +  w + ';'+
'height:' + h + ';">'+
'<img src="' + imgSrc + '" width="' + w + '" height="' + h + '">'+
'<//div>';
}


this.clear = function()
{
this.htm = "";
if (this.cnv) this.cnv.innerHTML = this.defhtm;
};


this.mkOvQds = function(cx, cy, xl, xr, yt, yb, w, h)
{
this.mkDiv(xr+cx, yt+cy, w, h);
this.mkDiv(xr+cx, yb+cy, w, h);
this.mkDiv(xl+cx, yb+cy, w, h);
this.mkDiv(xl+cx, yt+cy, w, h);
};

this.setStroke(1);
this.setFont('verdana,geneva,helvetica,sans-serif', String.fromCharCode(0x31, 0x32, 0x70, 0x78), Font.PLAIN);
this.color = '#000000';
this.htm = '';
this.wnd = wnd || window;

if (!(jg_ie || jg_dom || jg_ihtm)) chkDHTM();
if (typeof id != 'string' || !id) this.paint = pntDoc;
else
{
this.cnv = document.all? (this.wnd.document.all[id] || null)
: document.getElementById? (this.wnd.document.getElementById(id) || null)
: null;
this.defhtm = (this.cnv && this.cnv.innerHTML)? this.cnv.innerHTML : '';
this.paint = jg_dom? pntCnvDom : jg_ie? pntCnvIe : jg_ihtm? pntCnvIhtm : pntCnv;
}

this.setPrintable(false);
}

function integer_compare(x,y)
{
return (x < y) ? -1 : ((x > y)*1);
}

 

 


 

 

   JS 中,一些东西不可用的三种展现方式。
我 们在WEB项目中,有时候需要在用户点击某个东西的时候,一些东西不可用。如果在客户端实现。最简单的就是利用disabled 。下面罗列的其中三种方式:依次是:不可用(disabled);用一个空白来代替这个地方(Blank);这个区域为空(None)。具体可以查看这个 Blog的源文件:
obj.disabled = false;

obj.style.visibility = "hidden";

obj.style.display = "none";


<SCRIPT language=javascript>
function ShowDisableObject(obj)
{
 if(obj.disabled == false)
 {
  obj.disabled = true;
 }
 else{
  obj.disabled = false;
 }
 var coll = obj.all.tags("INPUT");
 if (coll!=null)
 {
  for (var i=0; i<coll.length; i++)
  {
   coll[i].disabled = obj.disabled;
  }
 }
}

function ShowBlankObject(obj)
{
 if(obj.style.visibility == "hidden")
 {
  obj.style.visibility = "visible";
 }
 else
 {
  obj.style.visibility = "hidden";
 }
}

function ShowNoneObject(obj)
{
 if(obj.style.display == "none")
 {
  obj.style.display = "block";
 }
 else
 {
  obj.style.display = "none";
 }
}

</SCRIPT>

<P></P>
<DIV id=Show01>dadd
<DIV>ccc</DIV><INPUT> <INPUT type=checkbox> </DIV>
<P><INPUT onclick=ShowDisableObject(Show01); type=button value=Disable> <INPUT id=Button1 onclick=ShowBlankObject(Show01); type=button value=Blank name=Button1> <INPUT id=Button2 onclick=ShowNoneObject(Show01); type=button value=None name=Button2> </P><!--演示代码结束//-->


On this page I explain a simple DHTML example script that features invisibility, moving and the changing of text colour.


Example
Test TextMake test text invisible.
Make test text visible.
Move test text 50 pixels down.
Move test text 50 pixels up.
Change colour to red.
Change colour to blue.
Change colour to black.
Change the font style to italic.
Change the font style to normal.
Change the font family to 'Times'.
Change the font family to 'Arial'.


The script
The scripts work on this HTML element:

<DIV ID="text">Test Text</DIV>

#text {position: absolute;
top: 400px;
left: 400px;
font: 18px arial;
font-weight: 700;
}

These scripts are necessary for the three effects:

var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
  if (document.getElementById)
  {
  this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
this.obj = document.all[name];
this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   this.obj = document.layers[name];
   this.style = document.layers[name];
  }
}

function invi(flag)
{
if (!DHTML) return;
var x = new getObj('text');
x.style.visibility = (flag) ? 'hidden' : 'visible'
}

var texttop = 400;

function move(amount)
{
if (!DHTML) return;
var x = new getObj('text');
texttop += amount;
x.style.top = texttop;
}


function changeCol(col)
{
if (!DHTML) return;
var x = new getObj('text');
x.style.color = col;
}

 


一段实现DataGrid的“编辑”、“取消”功能脚本,目的是不产生页面刷新
<SCRIPT language="javascript">
var selectRow="";
var selectObject;
function EditCell(thisObject,type)
{
var id = thisObject.id;
var buttonID="Button"+type;
var row=id.replace(buttonID,"");
if(type==1&&selectRow.length>0&&selectObject!=null)
{
EditRow(selectRow,2,selectObject);
selectRow="";
}
if(type==1){selectRow=row;selectObject=thisObject;}else{selectRow="";selectObject=null;}
EditRow(row,type,thisObject);
}

function EditRow(row,type,thisObject)
{
var visible1="none";
var visible2="inline";
if(type!=1)
{
visible1="inline";
visible2="none";
}
var buttonID="Button"+type;
var style;
var i;
for(i=1;i<8;i++)
{
var name1=row+"Img"+i;
document.all[name1].getAttribute("style").display=visible1;
name1=row+"Text"+i;
var name2=row+"Checkbox"+i;
document.all[name2].getAttribute("style").display=visible2;
if(type!=1)
{
if(document.all[name1].value==1)
document.all[name2].checked=true;
else
document.all[name2].checked=false;
}
}

var tdIndex = thisObject.parentElement.cellIndex;
if(type>1) tdIndex = tdIndex -1;
thisObject.parentElement.parentElement.cells[tdIndex].getAttribute("style").display=visible2;

thisObject.parentElement.colSpan=type;

var name;
name=row+buttonID;
document.all[name].getAttribute("style").display="none";

if(type==1)
{
document.all[name].parentElement.parentElement.getAttribute("style").backgroundColor="LightYellow";
name=row+"Button2";
document.all[name].getAttribute("style").display="inline";
}
else
{
document.all[name].parentElement.parentElement.getAttribute("style").backgroundColor="";
name=row+"Button1";
document.all[name].getAttribute("style").display="inline";
}
}

</SCRIPT>
<asp:datagrid id="GridItem" runat="server" cellPadding="0" BorderStyle="Solid" AutoGenerateColumns="False"
Width="100%" AllowPaging="True">
<SelectedItemStyle BackColor="LightYellow"></SelectedItemStyle>
<EditItemStyle CssClass="tdbg-dark" BackColor="Ivory"></EditItemStyle>
<ItemStyle HorizontalAlign="Center" Height="23px" CssClass="tdbg"></ItemStyle>
<HeaderStyle HorizontalAlign="Center" Height="25px" CssClass="summary-title"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="id" ReadOnly="True" HeaderText="人员编号">
<HeaderStyle Width="120px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn ReadOnly="True" HeaderText="姓名">
<HeaderStyle Width="120px"></HeaderStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="管理权">
<HeaderStyle Width="60px"></HeaderStyle>
<ItemTemplate>
<IMG id="Img1" style="DISPLAY: inline" alt="" src="Images/CheckBoxUnSelect.gif" runat="server"><INPUT id="Checkbox1" style="DISPLAY: none" type="checkbox" runat="server">
<INPUT id="Text1" type="text" runat="server" style="DISPLAY: none">
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="查询权">
<HeaderStyle Width="60px"></HeaderStyle>
<ItemTemplate>
<IMG id="Img2" style="DISPLAY: inline" alt="" src="Images/CheckBoxUnSelect.gif" runat="server"><INPUT id="Checkbox2" style="DISPLAY: none" type="checkbox" runat="server" NAME="Checkbox2">
<INPUT id="Text2" type="text" runat="server" style="DISPLAY: none" NAME="Text2">
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="录入权">
<HeaderStyle Width="60px"></HeaderStyle>
<ItemTemplate>
<IMG id="Img3" style="DISPLAY: inline" alt="" src="Images/CheckBoxUnSelect.gif" runat="server"><INPUT id="Checkbox3" style="DISPLAY: none" type="checkbox" runat="server" NAME="Checkbox3">
<INPUT id="Text3" type="text" runat="server" style="DISPLAY: none" NAME="Text3">
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="修改权">
<HeaderStyle Width="60px"></HeaderStyle>
<ItemTemplate>
<IMG id="Img4" style="DISPLAY: inline" alt="" src="Images/CheckBoxUnSelect.gif" runat="server"><INPUT id="Checkbox4" style="DISPLAY: none" type="checkbox" runat="server" NAME="Checkbox4">
<INPUT id="Text4" type="text" runat="server" style="DISPLAY: none" NAME="Text4">
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="删除权">
<HeaderStyle Width="60px"></HeaderStyle>
<ItemTemplate>
<IMG id="Img5" style="DISPLAY: inline" alt="" src="Images/CheckBoxUnSelect.gif" runat="server"><INPUT id="Checkbox5" style="DISPLAY: none" type="checkbox" runat="server" NAME="Checkbox5">
<INPUT id="Text5" type="text" runat="server" style="DISPLAY: none" NAME="Text5">
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="导出权">
<HeaderStyle Width="60px"></HeaderStyle>
<ItemTemplate>
<IMG id="Img6" style="DISPLAY: inline" alt="" src="Images/CheckBoxUnSelect.gif" runat="server"><INPUT id="Checkbox6" style="DISPLAY: none" type="checkbox" runat="server" NAME="Checkbox6">
<INPUT id="Text6" type="text" runat="server" style="DISPLAY: none" NAME="Text6">
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="导入权">
<HeaderStyle Width="60px"></HeaderStyle>
<ItemTemplate>
<IMG id="Img7" style="DISPLAY: inline" alt="" src="Images/CheckBoxUnSelect.gif" runat="server"><INPUT id="Checkbox7" style="DISPLAY: none" type="checkbox" runat="server" NAME="Checkbox7">
<INPUT id="Text7" type="text" runat="server" style="DISPLAY: none" NAME="Text7">
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="保存" HeaderText="操作" CommandName="cmdSave">
<ItemStyle Font-Size="10pt"></ItemStyle>
</asp:ButtonColumn>
<asp:TemplateColumn>
<ItemTemplate>
<INPUT id="Button1" style="cursor: hand; WIDTH: 35px; COLOR: blue; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline; BORDER-BOTTOM-STYLE: none"
onclick="EditCell(this,1);" type="button" value="编辑" runat="server"><INPUT id="Button2" style="cursor: hand; DISPLAY: none; COLOR: blue; BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline; BORDER-BOTTOM-STYLE: none"
onclick="EditCell(this,2);" type="button" value="取消" runat="server">
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle NextPageText="下一页" PrevPageText="上一页"></PagerStyle>
</asp:datagrid>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> DSTree </TITLE>
<META NAME="Author" CONTENT="sTarsjz@hotmail.com" >
<style>
body,td{font:12px verdana}
#treeBox{background-color:#fffffa;}
#treeBox .ec{margin:0 5 0 5;}
#treeBox .hasItems{font-weight:bold;height:20px;padding:3 6 0 6;margin:2px;cursor:hand;color:#555555;border:1px solid #fffffa;}
#treeBox .Items{height:20px;padding:3 6 0 6;margin:1px;cursor:hand;color:#555555;border:1px solid #fffffa;}
</style>
<base href="http://vip.5d.cn/star/dstree/" />
<script>
//code by star 20003-4-7
var HC = "color:#990000;border:1px solid #cccccc";
var SC = "background-color:#efefef;border:1px solid #cccccc;color:#000000;";
var IO = null;
function initTree(){
var rootn = document.all.menuXML.documentElement;
var sd = 0;
document.onselectstart = function(){return false;}
document.all.treeBox.appendChild(createTree(rootn,sd));
}
function createTree(thisn,sd){
var nodeObj = document.createElement("span");
var upobj = document.createElement("span");
with(upobj){
style.marginLeft = sd*10;
className = thisn.hasChildNodes()?"hasItems":"Items";
innerHTML = "<img src=http://www.blueidea.com/img/common/logo.gif class=ec>" + thisn.getAttribute("text") +"";

onmousedown = function(){
if(event.button != 1) return;
if(this.getAttribute("cn")){
this.setAttribute("open",!this.getAttribute("open"));
this.cn.style.display = this.getAttribute("open")?"inline":"none";
this.all.tags("img")[0].src = this.getAttribute("open")?"http://www.blueidea.com/img/common/logo.gif":"http://www.blueidea.com/img/common/logo.gif";
}
if(IO){
IO.runtimeStyle.cssText = "";
IO.setAttribute("selected",false);
}
IO = this;
this.setAttribute("selected",true);
this.runtimeStyle.cssText = SC;
}
onmouseover = function(){
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = HC;
}
onmouseout = function(){
if(this.getAttribute("selected"))return;
this.runtimeStyle.cssText = "";
}
oncontextmenu = contextMenuHandle;
onclick = clickHandle;
}

if(thisn.getAttribute("treeId") != null){
upobj.setAttribute("treeId",thisn.getAttribute("treeId"));
}
if(thisn.getAttribute("href") != null){
upobj.setAttribute("href",thisn.getAttribute("href"));
}
if(thisn.getAttribute("target") != null){
upobj.setAttribute("target",thisn.getAttribute("target"));
}

nodeObj.appendChild(upobj);
nodeObj.insertAdjacentHTML("beforeEnd","<br/>")

if(thisn.hasChildNodes()){
var i;
var nodes = thisn.childNodes;
var cn = document.createElement("span");
upobj.setAttribute("cn",cn);
if(thisn.getAttribute("open") != null){
upobj.setAttribute("open",(thisn.getAttribute("open")=="true"));
upobj.getAttribute("cn").style.display = upobj.getAttribute("open")?"inline":"none";
if( !upobj.getAttribute("open"))upobj.all.tags("img")[0].src ="http://www.blueidea.com/img/common/logo.gif";
}

for(i=0;i<nodes.length;cn.appendChild(createTree(nodes[i++],sd+1)));
nodeObj.appendChild(cn);
}
else{
upobj.all.tags("img")[0].src ="http://www.blueidea.com/img/common/logo.gif";
}
return nodeObj;
}
window.onload = initTree;
</script>

<script>
function clickHandle(){
// your code here
}
function contextMenuHandle(){
event.returnValue = false;
var treeId = this.getAttribute("treeId");
// your code here
}
</script>
</HEAD>
<BODY>
<xml id=menuXML>
<?xml version="1.0" encoding="GB2312"?>
<DSTreeRoot text="根节点" open="true" href="http://" _fcksavedurl=""http://"" treeId="123">

<DSTree text="技术论坛" open="false" treeId="">
<DSTree text="5DMedia" open="false" href="http://" target="box" treeId="12">
<DSTree text="网页编码" href="http://" target="box" treeId="4353" />
<DSTree text="手绘" href="http://" target="box" treeId="543543" />
<DSTree text="灌水" href="http://" target="box" treeId="543543" />
</DSTree>
<DSTree text="BlueIdea" open="false" href="http://" target="box" treeId="213">
<DSTree text="DreamWeaver &amp; JS" href="http://" target="box" treeId="4353" />
<DSTree text="FlashActionScript" href="http://" target="box" treeId="543543" />
</DSTree>
<DSTree text="CSDN" open="false" href="http://" target="box" treeId="432">
<DSTree text="JS" href="http://" target="box" treeId="4353" />
<DSTree text="XML" href="http://" target="box" treeId="543543" />
</DSTree>
</DSTree>

<DSTree text="资源站点" open="false" treeId="">
<DSTree text="素材屋" href="http://" target="box" treeId="12" />
<DSTree text="桌面城市" open="false" href="http://" target="box" treeId="213">
<DSTree text="壁纸" href="http://" target="box" treeId="4353" />
<DSTree text="字体" href="http://" target="box" treeId="543543" />
</DSTree>
<DSTree text="MSDN" open="false" href="http://" target="box" treeId="432">
<DSTree text="DHTML" href="http://" target="box" treeId="4353" />
<DSTree text="HTC" href="http://" target="box" treeId="543543" />
<DSTree text="XML" href="" target="box" treeId="2312" />
</DSTree>
</DSTree>

</DSTreeRoot>
</xml>
<table style="position:absolute;left:100;top:100;">
<tr><td id=treeBox style="width:400px;height:200px;border:1px solid #cccccc;padding:5 3 3 5;" valign=top></td></tr>
<tr><td style="font:10px verdana;color:#999999" align=right>by <font color=#660000>sTar</font><br/> 2003-4-8</td></tr>
</table>
</BODY>
</HTML>

 

针对javascript的几个对象的扩充函数
function checkBrowser()
{
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.mac=(this.ver.indexOf('Mac') > -1) ?1:0;
this.ope=(navigator.userAgent.indexOf('Opera')>-1);
this.ie=(this.ie6 || this.ie5 || this.ie4)
this.ns=(this.ns4 || this.ns5)
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns5 || this.ns4 || this.mac || this.ope)
this.nbw=(!this.bw)

return this;
}
/*
******************************************
日期函数扩充
******************************************
*/


/*
===========================================
//转换成大写日期(中文)
===========================================
*/
Date.prototype.toCase = function()
{
var digits= new Array('零','一','二','三','四','五','六','七','八','九','十','十一','十二');
var unit= new Array('年','月','日','点','分','秒');

var year= this.getYear() + "";
var index;
var output="";

////////得到年
for (index=0;index<year.length;index++ )
{
output += digits[parseInt(year.substr(index,1))];
}
output +=unit[0];

///////得到月
output +=digits[this.getMonth()] + unit[1];

///////得到日
switch (parseInt(this.getDate() / 10))
{
case 0:
output +=digits[this.getDate() % 10];
break;
case 1:
output +=digits[10] + ((this.getDate() % 10)>0?digits[(this.getDate() % 10)]:"");
break;
case 2:
case 3:
output +=digits[parseInt(this.getDate() / 10)] + digits[10]  + ((this.getDate() % 10)>0?digits[(this.getDate() % 10)]:"");
default:

break;
}
output +=unit[2];

///////得到时
switch (parseInt(this.getHours() / 10))
{
case 0:
output +=digits[this.getHours() % 10];
break;
case 1:
output +=digits[10] + ((this.getHours() % 10)>0?digits[(this.getHours() % 10)]:"");
break;
case 2:
output +=digits[parseInt(this.getHours() / 10)] + digits[10] + ((this.getHours() % 10)>0?digits[(this.getHours() % 10)]:"");
break;
}
output +=unit[3];

if(this.getMinutes()==0&&this.getSeconds()==0)
{
output +="整";
return output;
}

///////得到分
switch (parseInt(this.getMinutes() / 10))
{
case 0:
output +=digits[this.getMinutes() % 10];
break;
case 1:
output +=digits[10] + ((this.getMinutes() % 10)>0?digits[(this.getMinutes() % 10)]:"");
break;
case 2:
case 3:
case 4:
case 5:
output +=digits[parseInt(this.getMinutes() / 10)] + digits[10] + ((this.getMinutes() % 10)>0?digits[(this.getMinutes() % 10)]:"");
break;
}
output +=unit[4];

if(this.getSeconds()==0)
{
output +="整";
return output;
}

///////得到秒
switch (parseInt(this.getSeconds() / 10))
{
case 0:
output +=digits[this.getSeconds() % 10];
break;
case 1:
output +=digits[10] + ((this.getSeconds() % 10)>0?digits[(this.getSeconds() % 10)]:"");
break;
case 2:
case 3:
case 4:
case 5:
output +=digits[parseInt(this.getSeconds() / 10)] + digits[10] + ((this.getSeconds() % 10)>0?digits[(this.getSeconds() % 10)]:"");
break;
}
output +=unit[5];

 

return output;
}


/*
===========================================
//转换成农历
===========================================
*/
Date.prototype.toChinese = function()
{
//暂缺
}

/*
===========================================
//是否是闰年
===========================================
*/
Date.prototype.isLeapYear = function()
{
return (0==this.getYear()%4&&((this.getYear()%100!=0)||(this.getYear()%400==0)));
}

/*
===========================================
//获得该月的天数
===========================================
*/
Date.prototype.getDayCountInMonth = function()
{
var mon = new Array(12);

    mon[0] = 31; mon[1] = 28; mon[2] = 31; mon[3] = 30; mon[4]  = 31; mon[5]  = 30;
    mon[6] = 31; mon[7] = 31; mon[8] = 30; mon[9] = 31; mon[10] = 30; mon[11] = 31;

if(0==this.getYear()%4&&((this.getYear()%100!=0)||(this.getYear()%400==0))&&this.getMonth()==2)
{
return 29;
}
else
{
return mon[this.getMonth()];
}
}


/*
===========================================
//日期比较
===========================================
*/
Date.prototype.Compare = function(objDate)
{
if(typeof(objDate)!="object" && objDate.constructor != Date)
{
return -2;
}

var d = this.getTime() - objDate.getTime();

if(d>0)
{
return 1;
}
else if(d==0)
{
return 0;
}
else
{
return -1;
}
}

/*
===========================================
//格式化日期格式
===========================================
*/
Date.prototype.Format = function(formatStr)
{
var str = formatStr;

str=str.replace(/yyyy|YYYY/,this.getFullYear());
str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():"0" + (this.getYear() % 100));

str=str.replace(/MM/,this.getMonth()>9?this.getMonth().toString():"0" + this.getMonth());
str=str.replace(/M/g,this.getMonth());

str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():"0" + this.getDate());
str=str.replace(/d|D/g,this.getDate());

str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():"0" + this.getHours());
str=str.replace(/h|H/g,this.getHours());

str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():"0" + this.getMinutes());
str=str.replace(/m/g,this.getMinutes());

str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():"0" + this.getSeconds());
str=str.replace(/s|S/g,this.getSeconds());

return str;
}


/*
===========================================
//由字符串直接实例日期对象
===========================================
*/
Date.prototype.instanceFromString = function(str)
{
return new Date("2004-10-10".replace(/-/g, "//"));
}

/*
===========================================
//得到日期年月日等加数字后的日期
===========================================
*/
Date.prototype.dateAdd = function(interval,number)
{
var date = this;

    switch(interval)
    {
        case "y" :
            date.setFullYear(date.getFullYear()+number);
            return date;

        case "q" :
            date.setMonth(date.getMonth()+number*3);
            return date;

        case "m" :
            date.setMonth(date.getMonth()+number);
            return date;

        case "w" :
            date.setDate(date.getDate()+number*7);
            return date;
       
        case "d" :
            date.setDate(date.getDate()+number);
            return date;

        case "h" :
            date.setHours(date.getHours()+number);
            return date;

case "m" :
            date.setMinutes(date.getMinutes()+number);
            return date;

case "s" :
            date.setSeconds(date.getSeconds()+number);
            return date;

        default :
            date.setDate(d.getDate()+number);
            return date;
    }
}

/*
===========================================
//计算两日期相差的日期年月日等
===========================================
*/
Date.prototype.dateDiff = function(interval,objDate)
{
//暂缺
}


/*
******************************************
数字函数扩充
******************************************
*/

/*
===========================================
//转换成中文大写数字
===========================================
*/
Number.prototype.toChinese = function()
{
var num = this;
    if(!/^/d*(/./d*)?$/.test(num)){alert("Number is wrong!"); return "Number is wrong!";}

    var AA = new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖");
    var BB = new Array("","拾","佰","仟","萬","億","点","");
   
    var a = (""+ num).replace(/(^0*)/g, "").split("."), k = 0, re = "";

    for(var i=a[0].length-1; i>=0; i--)
    {
        switch(k)
        {
            case 0 : re = BB[7] + re; break;
            case 4 : if(!new RegExp("0{4}//d{"+ (a[0].length-i-1) +"}$").test(a[0]))
                     re = BB[4] + re; break;
            case 8 : re = BB[5] + re; BB[7] = BB[5]; k = 0; break;
        }
        if(k%4 == 2 && a[0].charAt(i+2) != 0 && a[0].charAt(i+1) == 0) re = AA[0] + re;
        if(a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k%4] + re; k++;
    }

    if(a.length>1) //加上小数部分(如果有小数部分)
    {
        re += BB[6];
        for(var i=0; i<a[1].length; i++) re += AA[a[1].charAt(i)];
    }
    return re;

}

/*
===========================================
//保留小数点位数
===========================================
*/
Number.prototype.toFixed=function(len)
{

if(isNaN(len)||len==null)
{
len = 0;
}
else
{
if(len<0)
{
len = 0;
}
}

    return Math.round(this * Math.pow(10,len)) / Math.pow(10,len);

}

/*
===========================================
//转换成大写金额
===========================================
*/
Number.prototype.toMoney = function()
{
// Constants:
var MAXIMUM_NUMBER = 99999999999.99;
// Predefine the radix characters and currency symbols for output:
var CN_ZERO= "零";
var CN_ONE= "壹";
var CN_TWO= "贰";
var CN_THREE= "叁";
var CN_FOUR= "肆";
var CN_FIVE= "伍";
var CN_SIX= "陆";
var CN_SEVEN= "柒";
var CN_EIGHT= "捌";
var CN_NINE= "玖";
var CN_TEN= "拾";
var CN_HUNDRED= "佰";
var CN_THOUSAND = "仟";
var CN_TEN_THOUSAND= "万";
var CN_HUNDRED_MILLION= "亿";
var CN_SYMBOL= "";
var CN_DOLLAR= "元";
var CN_TEN_CENT = "角";
var CN_CENT= "分";
var CN_INTEGER= "整";
 
// Variables:
var integral; // Represent integral part of digit number.
var decimal; // Represent decimal part of digit number.
var outputCharacters; // The output result.
var parts;
var digits, radices, bigRadices, decimals;
var zeroCount;
var i, p, d;
var quotient, modulus;
 
if (this > MAXIMUM_NUMBER)
{
return "";
}
 
// Process the coversion from currency digits to characters:
// Separate integral and decimal parts before processing coversion:

 parts = (this + "").split(".");
if (parts.length > 1)
{
integral = parts[0];
decimal = parts[1];
// Cut down redundant decimal digits that are after the second.
decimal = decimal.substr(0, 2);
}
else
{
integral = parts[0];
decimal = "";
}
// Prepare the characters corresponding to the digits:
digits= new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
radices= new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
bigRadices= new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
decimals= new Array(CN_TEN_CENT, CN_CENT);

 // Start processing:
 outputCharacters = "";
// Process integral part if it is larger than 0:
if (Number(integral) > 0)
{
zeroCount = 0;
for (i = 0; i < integral.length; i++)
{
p = integral.length - i - 1;
d = integral.substr(i, 1);
quotient = p / 4;
modulus = p % 4;
if (d == "0")
{
zeroCount++;
}
else
{
if (zeroCount > 0)
{
outputCharacters += digits[0];
}
zeroCount = 0;
outputCharacters += digits[Number(d)] + radices[modulus];
}

if (modulus == 0 && zeroCount < 4)
{
outputCharacters += bigRadices[quotient];
}
}

outputCharacters += CN_DOLLAR;
}

// Process decimal part if there is:
if (decimal != "")
{
for (i = 0; i < decimal.length; i++)
{
d = decimal.substr(i, 1);
if (d != "0")
{
outputCharacters += digits[Number(d)] + decimals[i];
}
}
}

// Confirm and return the final output string:
if (outputCharacters == "")
{
outputCharacters = CN_ZERO + CN_DOLLAR;
}
if (decimal == "")
{
outputCharacters += CN_INTEGER;
}

outputCharacters = CN_SYMBOL + outputCharacters;
return outputCharacters;
}


Number.prototype.toImage = function()
{
var num = Array(
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x5,0x5,0x5,0xF}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0x4,0x4,0x4,0x4,0x4}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x4,0xF,0x1,0xF}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x4,0xF,0x4,0xF}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0x5,0x5,0xF,0x4,0x4}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x1,0xF,0x4,0xF}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x1,0xF,0x5,0xF}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x4,0x4,0x4,0x4}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x5,0xF,0x5,0xF}",
"#define t_width 3/n#define t_height 5/nstatic char t_bits[] = {0xF,0x5,0xF,0x4,0xF}"
);

var str = this + "";
var iIndex
var result=""
for(iIndex=0;iIndex<str.length;iIndex++)
{
result +="<img src='javascript:" & num(iIndex) & "'">
}

return result;
}


/*
******************************************
其他函数扩充
******************************************
*/


/*
===========================================
//验证类函数
===========================================
*/
function IsEmpty(obj)
{

    obj=document.getElementsByName(obj).item(0);
    if(Trim(obj.value)=="")
    {
     
        if(obj.disabled==false && obj.readOnly==false)
        {
            obj.focus();
        }
return true;
    }
else
{
return false;
}
}

/*
===========================================
//无模式提示对话框
===========================================
*/
function modelessAlert(Msg)
{
   window.showModelessDialog("javascript:alert(/""+escape(Msg)+"/");window.close();","","status:no;resizable:no;help:no;dialogHeight:height:30px;dialogHeight:40px;");
}

 

/*
===========================================
//页面里回车到下一控件的焦点
===========================================
*/
function Enter2Tab()
{
var e = document.activeElement;
if(e.tagName == "INPUT" &&
(
e.type == "text"     ||
e.type == "password" ||
e.type == "checkbox" ||
e.type == "radio"
)   ||
e.tagName == "SELECT")

{
if(window.event.keyCode == 13)
{
    window.event.keyCode = 9;
}
}
}
////////打开此功能请取消下行注释
//document.onkeydown = Enter2Tab;


function ViewSource(url)
{
window.location = 'view-source:'+ url;
}

///////禁止右键
document.oncontextmenu = function() { return false;}

 


/*
******************************************
字符串函数扩充
******************************************
*/

/*
===========================================
//去除左边的空格
===========================================

*/
String.prototype.LTrim = function()
{
return this.replace(/(^/s*)/g, "");
}


String.prototype.Mid = function(start,len)
{
if(isNaN(start)&&start<0)
{
return "";
}

if(isNaN(len)&&len<0)
{
return "";
}

return this.substring(start,len);
}


/*
===========================================
//去除右边的空格
===========================================
*/
String.prototype.Rtrim = function()
{
return this.replace(/(/s*$)/g, "");
}

 

/*
===========================================
//去除前后空格
===========================================
*/
String.prototype.Trim = function()
{
return this.replace(/(^/s*)|(/s*$)/g, "");
}

/*
===========================================
//得到左边的字符串
===========================================
*/
String.prototype.Left = function(len)
{

if(isNaN(len)||len==null)
{
len = this.length;
}
else
{
if(parseInt(len)<0||parseInt(len)>this.length)
{
len = this.length;
}
}

return this.substring(0,len);
}


/*
===========================================
//得到右边的字符串
===========================================
*/
String.prototype.Right = function(len)
{

if(isNaN(len)||len==null)
{
len = this.length;
}
else
{
if(parseInt(len)<0||parseInt(len)>this.length)
{
len = this.length;
}
}

return this.substring(this.length-len,this.length);
}


/*
===========================================
//得到中间的字符串,注意从0开始
===========================================
*/
String.prototype.Mid = function(start,len)
{
if(isNaN(start)||start==null)
{
start = 0;
}
else
{
if(parseInt(start)<0)
{
start = 0;
}
}

if(isNaN(len)||len==null)
{
len = this.length;
}
else
{
if(parseInt(len)<0)
{
len = this.length;
}
}

return this.substring(start,start+len);
}


/*
===========================================
//在字符串里查找另一字符串:位置从0开始
===========================================
*/
String.prototype.InStr = function(str)
{

if(str==null)
{
str = "";
}

return this.indexOf(str);
}

/*
===========================================
//在字符串里反向查找另一字符串:位置0开始
===========================================
*/
String.prototype.InStrRev = function(str)
{

if(str==null)
{
str = "";
}

return this.lastIndexOf(str);
}

 

/*
===========================================
//计算字符串打印长度
===========================================
*/
String.prototype.LengthW = function()
{
return this.replace(/[^/x00-/xff]/g,"**").length;
}

/*
===========================================
//是否是正确的IP地址
===========================================
*/
String.prototype.isIP = function()
{

var reSpaceCheck = /^(/d+)/.(/d+)/.(/d+)/.(/d+)$/;

if (reSpaceCheck.test(this))
{
this.match(reSpaceCheck);
if (RegExp.$1 <= 255 && RegExp.$1 >= 0
 && RegExp.$2 <= 255 && RegExp.$2 >= 0
 && RegExp.$3 <= 255 && RegExp.$3 >= 0
 && RegExp.$4 <= 255 && RegExp.$4 >= 0)
{
return true;    
}
else
{
return false;
}
}
else
{
return false;
}
  
}

 

 

/*
===========================================
//是否是正确的长日期
===========================================
*/
String.prototype.isDate = function()
{
var r = str.match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2}) (/d{1,2}):(/d{1,2}):(/d{1,2})$/);
if(r==null)
{
return false;
}
var d = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);

}

/*
===========================================
//是否是手机
===========================================
*/
String.prototype.isMobile = function()
{
return /^0{0,1}13[0-9]{9}$/.test(this);
}

/*
===========================================
//是否是邮件
===========================================
*/
String.prototype.isEmail = function()
{
return /^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/.test(this);
}

/*
===========================================
//是否是邮编(中国)
===========================================
*/

String.prototype.isZipCode = function()
{
return /^[//d]{6}$/.test(this);
}

/*
===========================================
//是否是有汉字
===========================================
*/
String.prototype.existChinese = function()
{
//[/u4E00-/u9FA5]為漢字﹐[/uFE30-/uFFA0]為全角符號
return /^[/x00-/xff]*$/.test(this);
}

/*
===========================================
//是否是合法的文件名/目录名
===========================================
*/
String.prototype.isFileName = function()
{
return !/[/////*/?/|:"<>]/g.test(this);
}

/*
===========================================
//是否是有效链接
===========================================
*/
String.Prototype.isUrl = function()
{
return /^http:////([/w-]+/.)+[/w-]+(/[/w-./?%&=]*)?$/.test(this);
}

/*
===========================================
//是否是有效的身份证(中国)
===========================================
*/
String.prototype.isIDCard = function()
{
var iSum=0;
var info="";
var sId = this;

var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};

if(!/^/d{17}(/d|x)$/i.test(sId))
{
return false;
}
sId=sId.replace(/x$/i,"a");
//非法地区
if(aCity[parseInt(sId.substr(0,2))]==null)
{
return false;
}

var sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));

var d=new Date(sBirthday.replace(/-/g,"/"))

//非法生日
if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))
{
return false;
}
for(var i = 17;i>=0;i--)
{
iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11);
}

if(iSum%11!=1)
{
return false;
}
return true;

}

/*
===========================================
//是否是有效的电话号码(中国)
===========================================
*/
String.prototype.isPhoneCall = function()
{
return /(^[0-9]{3,4}/-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/.test(this);
}


/*
===========================================
//是否是数字
===========================================
*/
String.prototype.isNumeric = function(flag)
{
//验证是否是数字
if(isNaN(this))
{

return false;
}

switch(flag)
{

case null://数字
case "":
return true;
case "+"://正数
return/(^/+?|^/d?)/d*/.?/d+$/.test(this);
case "-"://负数
return/^-/d*/.?/d+$/.test(this);
case "i"://整数
return/(^-?|^/+?|/d)/d+$/.test(this);
case "+i"://正整数
return/(^/d+$)|(^/+?/d+$)/.test(this);
case "-i"://负整数
return/^[-]/d+$/.test(this);
case "f"://浮点数
return/(^-?|^/+?|^/d?)/d*/./d+$/.test(this);
case "+f"://正浮点数
return/(^/+?|^/d?)/d*/./d+$/.test(this);
case "-f"://负浮点数
return/^[-]/d*/./d$/.test(this);
default://缺省
return true;
}
}


/*
===========================================
//转换成全角
===========================================
*/
String.prototype.toCase = function()
{
var tmp = "";
for(var i=0;i<this.length;i++)
{
if(this.charCodeAt(i)>0&&this.charCodeAt(i)<255)
{
tmp += String.fromCharCode(this.charCodeAt(i)+65248);
}
else
{
tmp += String.fromCharCode(this.charCodeAt(i));
}
}
return tmp
}

/*
===========================================
//对字符串进行Html编码
===========================================
*/
String.prototype.toHtmlEncode = function
{
var str = this;

str=str.replace("&","&amp;");
str=str.replace("<","&lt;");
str=str.replace(">","&gt;");
str=str.replace("'","&apos;");
str=str.replace("/"","&quot;");

return str;
}

 

qqdao(青青岛)
 
 
  精心整理的输入判断js函数

关键词:字符串判断,字符串处理,字串判断,字串处理


//'*********************************************************
// ' Purpose: 判断输入是否为整数字
// ' Inputs:   String
// ' Returns:  True, False
//'*********************************************************
function onlynumber(str)
{
    var i,strlength,tempchar;
    str=CStr(str);
   if(str=="") return false;
    strlength=str.length;
    for(i=0;i<strlength;i++)
    {
        tempchar=str.substring(i,i+1);
        if(!(tempchar==0||tempchar==1||tempchar==2||tempchar==3||tempchar==4||tempchar==5||tempchar==6||tempchar==7||tempchar==8||tempchar==9))
        {
        alert("只能输入数字 ");
        return false;
        }
    }
    return true;
}
//'*********************************************************


//'*********************************************************
// ' Purpose: 判断输入是否为数值(包括小数点)
// ' Inputs:   String
// ' Returns:  True, False
//'*********************************************************
function IsFloat(str)
{ var tmp;
   var temp;
   var i;
   tmp =str;
if(str=="") return false; 
for(i=0;i<tmp.length;i++)
{temp=tmp.substring(i,i+1);
if((temp>='0'&& temp<='9')||(temp=='.')){} //check input in 0-9 and '.'
else   { return false;}
}
return true;
}

 

//'*********************************************************
// ' Purpose: 判断输入是否为电话号码
// ' Inputs:   String
// ' Returns:  True, False
//'*********************************************************
function isphonenumber(str)
{
   var i,strlengh,tempchar;
   str=CStr(str);
   if(str=="") return false;
   strlength=str.length;
   for(i=0;i<strlength;i++)
   {
        tempchar=str.substring(i,i+1);
        if(!(tempchar==0||tempchar==1||tempchar==2||tempchar==3||tempchar==4||tempchar==5||tempchar==6||tempchar==7||tempchar==8||tempchar==9||tempchar=='-'))
        {
        alert("电话号码只能输入数字和中划线 ");
        return(false);
        }   
   }
   return(true);
}
//'*********************************************************

//'*********************************************************
// ' Purpose: 判断输入是否为Email
// ' Inputs:   String
// ' Returns:  True, False
//'*********************************************************
function isemail(str)
{
    var bflag=true
       
    if (str.indexOf("'")!=-1) {
        bflag=false
    }
    if (str.indexOf("@")==-1) {
        bflag=false
    }
    else if(str.charAt(0)=="@"){
            bflag=false
    }
    return bflag
}

//'*********************************************************
// ' Purpose: 判断输入是否含有为中文
// ' Inputs:   String
// ' Returns:  True, False
//'*********************************************************
function IsChinese(str) 
{
if(escape(str).indexOf("%u")!=-1)
  {
    return true;
  }
    return false;
}
//'*********************************************************


//'*********************************************************
// ' Purpose: 判断输入是否含有空格
// ' Inputs:   String
// ' Returns:  True, False
//'*********************************************************
function checkblank(str)
{
var strlength;
var k;
var ch;
strlength=str.length;
for(k=0;k<=strlength;k++)
  {
     ch=str.substring(k,k+1);
     if(ch==" ")
      {
      alert("对不起 不能输入空格 "); 
      return false;
      }
  }
return true;
}
//'*********************************************************

 

                                       
//'*********************************************************
// ' Purpose: 去掉Str两边空格
// ' Inputs:   Str
// ' Returns:  去掉两边空格的Str
//'*********************************************************
function trim(str)
{
    var i,strlength,t,chartemp,returnstr;
    str=CStr(str);
    strlength=str.length;
    t=str;
    for(i=0;i<strlength;i++)
    {
        chartemp=str.substring(i,i+1);   
        if(chartemp==" ")
        {
            t=str.substring(i+1,strlength);
        }
        else
        {
               break;
        }
    }
    returnstr=t;
    strlength=t.length;
    for(i=strlength;i>=0;i--)
    {
        chartemp=t.substring(i,i-1);
        if(chartemp==" ")
        {
            returnstr=t.substring(i-1,0);
        }
        else
        {
            break;
        }
    }
    return (returnstr);
}

//'*********************************************************


//'*********************************************************
// ' Purpose: 将数值类型转化为String
// ' Inputs:   int
// ' Returns:  String
//'*********************************************************
function CStr(inp)
{
    return(""+inp+"");
}
//'*********************************************************


//'*********************************************************
// ' Purpose: 去除不合法字符,   ' " < >
// ' Inputs:   String
// ' Returns:  String
//'*********************************************************
function Rep(str)
{var str1;
str1=str;
str1=replace(str1,"'","`",1,0);
str1=replace(str1,'"',"`",1,0);
str1=replace(str1,"<","(",1,0);
str1=replace(str1,">",")",1,0);
return str1;
}
//'*********************************************************

//'*********************************************************
// ' Purpose: 替代字符
// ' Inputs:   目标String,欲替代的字符,替代成为字符串,大小写是否敏感,是否整字代替
// ' Returns:  String
//'*********************************************************
function replace(target,oldTerm,newTerm,caseSens,wordOnly)
{ var wk ;
  var ind = 0;
  var next = 0;
  wk=CStr(target);
  if (!caseSens)
   {
      oldTerm = oldTerm.toLowerCase();   
      wk = target.toLowerCase();
    }
  while ((ind = wk.indexOf(oldTerm,next)) >= 0)
  { 
         if (wordOnly) 
              {
                  var before = ind - 1;    
                var after = ind + oldTerm.length;
                  if (!(space(wk.charAt(before)) && space(wk.charAt(after))))
                    {
                      next = ind + oldTerm.length;    
                       continue;     
                   }
          }
     target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length);
     wk = wk.substring(0,ind) + newTerm + wk.substring(ind+oldTerm.length,wk.length);
     next = ind + newTerm.length;   
     if (next >= wk.length) { break; }
  }
  return target;
}
//'*********************************************************
 

 

几个判断,并强制设置焦点:
//+------------------------------------
// trim     去除字符串两端的空格
String.prototype.trim=function(){return this.replace(/(^/s*)|(/s*$)/g,"")}
//-------------------------------------

// avoidDeadLock 避免设置焦点死循环问题
// 起死原因:以文本框为例,当一个文本框的输入不符合条件时,这时,鼠标点击另一个文本框,触发第一个文本框的离开事件
//   ,产生设置焦点动作。现在产生了第二个文本框的离开事件,因此也要设置第二个文本框的焦点,造成死锁。
// 解决方案:设置一个全局对象[key],记录当前触发事件的对象,若其符合条件,则释放该key;若其仍不符合,则key还是指
//   向该对象,别的对象触发不到设置焦点的语句。
/////////////////////////////////////////
// 文本框控制函数
//
/////////////////////////////////////////
var g_Obj = null;// 记住旧的控件
// hintFlag参数:0表示没有被别的函数调用,因此出现提示;1表示被调用,不出现警告信息
// focusFlag参数:指示是否要设置其焦点,分情况:0表示有的可为空;1表示有的不为空
// 避免死锁的公共部分
//+------------------------------------
function textCom(obj, hintFlag)
{
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}
g_Obj.value = g_Obj.value.trim();
}
//-------------------------------------
// 文本框不为空
//+------------------------------------
function TBNotNull(obj, hintFlag)
{
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}
g_Obj.value = g_Obj.value.trim();

if (g_Obj.value == "")
{
if (hintFlag == 0)
{
g_Obj.focus();
alert("内容不能为空!");
}
return false;
}
else
g_Obj = null;

return true;
}
//-------------------------------------
// 输入内容为数字
//+------------------------------------
function LetNumber(obj, hintFlag, focusFlag)
{
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}
g_Obj.value = g_Obj.value.trim();

if ((g_Obj.value == "") || isNaN(g_Obj.value))
{
if (hintFlag == 0)
{

g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
g_Obj = null;
alert("输入的内容必须为数字!");
}
return false;
}
else
g_Obj = null;

return true;
}
//-------------------------------------
// 输入内容为整数
//+------------------------------------
function LetInteger(obj, hintFlag, focusFlag)
{
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}
g_Obj.value = g_Obj.value.trim();

if (!/^/d*$/.test(g_Obj.value) || (g_Obj.value == ""))
{
if (hintFlag == 0)
{

g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
g_Obj = null;
alert("输入的内容必须为整数!");
}
return false;
}
else
g_Obj = null;

return true;
}
//-------------------------------------
// 输入内容为字母
//+------------------------------------
function LetLetter(obj, hintFlag, focusFlag)
{
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}

if (!/^[A-Za-z]*$/.test(g_Obj.value))
{
if (hintFlag == 0)
{
alert("输入的内容必须为字母!");
g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
g_Obj = null;
}
return false;
}
else
{
g_Obj = null;
}

return true;
}
//-------------------------------------
// 内容大于某值
//+------------------------------------
function LetMoreThan(obj, leftNumber, hintFlag, focusFlag)
{
var ifAlert;// 是否出现警告
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}

g_Obj.value = g_Obj.value.trim();
if (g_Obj.value == "")
ifAlert = 0;
else
ifAlert = 1;

if ((g_Obj.value == "") || (isNaN(g_Obj.value)) || (g_Obj.value < leftNumber))
{
if (hintFlag == 0)
{
g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
g_Obj = null;
// 更友好的提示
if (ifAlert == 1)
{
if (leftNumber == 0)
alert("内容必须为非负数!");
else
alert("输入的内容必须" + leftNumber + "以上!");
}
}
return false;
}
else
g_Obj = null;

return true;
}
//-------------------------------------
// 内容大于某值,整数
//+------------------------------------
function LetMoreThan_Int(obj, leftNumber, hintFlag, focusFlag)
{
var ifAlert;// 是否出现警告
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}
g_Obj.value = g_Obj.value.trim();
if (g_Obj.value == "")
ifAlert = 0;
else
ifAlert = 1;
if ((g_Obj.value == "") || (isNaN(g_Obj.value) || g_Obj.value < leftNumber) || !/^/d*$/.test(g_Obj.value))
{
if (hintFlag == 0)
{
g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
{g_Obj = null;}
if (ifAlert == 1)// 当用户不输入的时候,不出现提示
{
// 更友好的提示
if (leftNumber == 0)
alert("内容必须为非负整数!");
else
alert("且必须在" + leftNumber + "以上!");
}
}
return false;
}
else
g_Obj = null;

return true;
}
//-------------------------------------
// 内容小于某值
//+------------------------------------
function LetLessThan(obj, rightNumber, hintFlag, focusFlag)
{
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}
g_Obj.value = g_Obj.value.trim();

if ((g_Obj.value == "") || (isNaN(g_Obj.value) || g_Obj.value > rightNumber))
{
if (hintFlag == 0)
{
g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
g_Obj = null;
alert("输入的内容必须在" + rightNumber + "以下!");
}
return false;
}
else
{g_Obj = null;}

return true;
}
//-------------------------------------
// 内容介于两值中间
//+------------------------------------
function LetMid(obj, leftNumber, rightNumber, hintFlag, focusFlag)
{
var ifAlert;// 是否出现警告
if (g_Obj == null)
g_Obj=event.srcElement;
else if ((g_Obj != null) && (hintFlag == 0) && (g_Obj != obj))
{
g_Obj = null;
return;
}
g_Obj.value = g_Obj.value.trim();
if (g_Obj.value == "")
ifAlert = 0;
else
ifAlert = 1;
// 首先应该为数字
if (LetNumber(g_Obj, 1))
{
if (!(LetMoreThan(obj,leftNumber,1,0) && LetLessThan(obj,rightNumber,1,0)))
{
if (hintFlag == 0)
{
g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
g_Obj = null;
if (ifAlert == 1)// 当用户不输入的时候,不出现提示
alert("输入的内容必须介于" + leftNumber + "和" + rightNumber + "之间!");
}

return false;
}
else
{g_Obj = null;}
}
else
{
if (hintFlag == 0)
{

g_Obj.value = "";
if (focusFlag == 1)
g_Obj.focus();
else
g_Obj = null;
if (ifAlert == 1)
alert("输入的内容必须为数字!/n" +
"且介于" + leftNumber + "和" + rightNumber + "之间!");
}

return false;
}

return true;
}
//-------------------------------------
/////////////////////////////////////////
// 下拉框
/////////////////////////////////////////
// 下拉框,务必选择
//+------------------------------------
function onSelLostFocus(obj)
{
if (g_Obj == null)
{
g_Obj=event.srcElement;
}
else if ((g_Obj!=null) && (g_Obj!=obj))
{
g_Obj = null;
return;
}

if (g_Obj.selectedIndex == 0)
{
g_Obj.focus();
}
else
{
g_Obj = null;
}
}


/*
    随风JavaScript函数库
  请把经过测试的函数加入库
*/


/********************
函数名称:StrLenthByByte
函数功能:计算字符串的字节长度,即英文算一个,中文算两个字节
函数参数:str,为需要计算长度的字符串
********************/
function StrLenthByByte(str)
{
var len;
var i;
len = 0;
for (i=0;i<str.length;i++)
{
if (str.charCodeAt(i)>255) len+=2; else len++;
}
return len;
}

/********************
函数名称:IsEmailAddress
函数功能:检查Email邮件地址的合法性,合法返回true,反之,返回false
函数参数:obj,需要检查的Email邮件地址
********************/
function IsEmailAddress(obj)
{
var pattern=/^[a-zA-Z0-9/-]+@[a-zA-Z0-9/-/.]+/.([a-zA-Z]{2,3})$/;
if(pattern.test(obj))
{
return true;
}
else
{
return false;
}
}

/********************
函数名称:PopWindow
函数功能:弹出新窗口
函数参数:pageUrl,新窗口地址;WinWidth,窗口的宽;WinHeight,窗口的高
********************/
function PopWindow(pageUrl,WinWidth,WinHeight)
{
var popwin=window.open(pageUrl,"PopWin","scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width="+WinWidth+",height="+WinHeight);
return false;
}

/********************
函数名称:PopRemoteWindow
函数功能:弹出可以控制父窗体的原程窗口
函数参数:pageUrl,新窗口地址;
调用方法:打开窗口:<a href="javascript:popRemoteWindow(url);">Open</a>
          控制父窗体:opener.location=url;当然还可以有其他的控制
********************/
function PopRemoteWindow(pageUrl)
{
var remote=window.open(url,"RemoteWindow","scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes");
if(remote.opener==null)
{
remote.opener=window;
}
}


/********************
函数名称:IsTelephone
函数功能:固话,手机号码检查函数,合法返回true,反之,返回false
函数参数:obj,待检查的号码
检查规则:
  (1)电话号码由数字、"("、")"和"-"构成
  (2)电话号码为3到8位
  (3)如果电话号码中包含有区号,那么区号为三位或四位
  (4)区号用"("、")"或"-"和其他部分隔开
  (5)移动电话号码为11或12位,如果为12位,那么第一位为0
  (6)11位移动电话号码的第一位和第二位为"13"
  (7)12位移动电话号码的第二位和第三位为"13"
********************/
function IsTelephone(obj)
{
var pattern=/(^[0-9]{3,4}/-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/;
if(pattern.test(obj))
{
return true;
}
else
{
return false;
}
}

/********************
函数名称:IsLegality
函数功能:检查字符串的合法性,即是否包含" '字符,包含则返回false;反之返回true
函数参数:obj,需要检测的字符串
********************/
function IsLegality(obj)
{
var intCount1=obj.indexOf("/"",0);
var intCount2=obj.indexOf("/'",0);
if(intCount1>0 || intCount2>0)
{
return false;
}
else
{
return true;
}
}

/********************
函数名称:IsNumber
函数功能:检测字符串是否全为数字
函数参数:str,需要检测的字符串
********************/
function IsNumber(str)
{
var number_chars = "1234567890";
var i;
for (i=0;i<str.length;i++)
{
if (number_chars.indexOf(str.charAt(i))==-1) return false;
}
return true;
}

/********************
函数名称:Trim
函数功能:去除字符串两边的空格
函数参数:str,需要处理的字符串
********************/
function Trim(str)
{
return str.replace(/(^/s*)|(/s*$)/g, "");
}

/********************
函数名称:LTrim
函数功能:去除左边的空格
函数参数:str,需要处理的字符串
********************/
function LTrim(str)
{
return str.replace(/(^/s*)/g, "");
}

/********************
函数名称:RTrim
函数功能:去除右边的空格
函数参数:str,需要处理的字符串
********************/
function RTrim(str)
{
 return this.replace(/(/s*$)/g, "");
}

/********************
函数名称:IsNull
函数功能:判断给定字符串是否为空
函数参数:str,需要处理的字符串
********************/
function IsNull(str)
{
if(Trim(str)=="")
{
return false;
}
else
{
return true;
}
}

/********************
函数名称:CookieEnabled
函数功能:判断cookie是否开启
********************/
function CookieEnabled()
{
return (navigator.cookieEnabled)? true : false;
}


/*字符串替换方法*/
function StrReplace(srcString,findString,replaceString,start)
{
//code
}

/*客户端HTML编码*/
function HtmlEncode(str)
{
//code
}


/********************************************************************
**
*函数功能:判断是否是闰年*
*输入参数:数字字符串*
*返回值:true,是闰年/false,其它*
*调用函数:*
**
********************************************************************/
function IsLeapYear(iYear)
{
if (iYear+"" == "undefined" || iYear+""== "null" || iYear+"" == "")
return false;

iYear = parseInt(iYear);
varisValid= false;

if((iYear % 4 == 0 && iYear % 100 != 0) || iYear % 400 == 0)
isValid= true;

return isValid;  
}
/********************************************************************
**
*函数功能:取出指定年、月的最后一天*
*输入参数:年份,月份*
*返回值:某年某月的最后一天*
*调用函数:IsLeapYear*
**
********************************************************************/
function GetLastDay(iYear,iMonth)
{
iYear = parseInt(iYear);
iMonth = parseInt(iMonth);

variDay = 31;

if((iMonth==4||iMonth==6||iMonth==9||iMonth==11)&&iDay == 31)
iDay = 30;

if(iMonth==2 )
if (IsLeapYear(iYear))
iDay = 29;
else
iDay = 28;
 return iDay;  
}
/********************************************************************
**
*函数功能:去字符串的头空和尾空*
*输入参数:字符串*
*返回值:字符串/null如果输入字符串不正确*
*调用函数:TrimLeft() 和 TrimRight()*
**
********************************************************************/
function Trim( str )
{
varresultStr ="";

resultStr =TrimLeft(str);
resultStr =TrimRight(resultStr);

return resultStr;
}

/********************************************************************
**
*函数功能:去字符串的头空*
*输入参数:字符串*
*返回值:字符串/null如果输入字符串不正确*
*调用函数:*
**
********************************************************************/
function TrimLeft( str )
{
varresultStr ="";
vari =len= 0;

if (str+"" == "undefined" || str ==null)
return null;

str+= "";

if (str.length == 0)
resultStr ="";
else
{
len= str.length;

while ((i <= len) && (str.charAt(i)== " "))
i++;

resultStr =str.substring(i, len);
}

return resultStr;
}

/********************************************************************
**
*函数功能:去字符串的尾空*
*输入参数:字符串*
*返回值:字符串/null如果输入字符串不正确*
*调用函数:*
**
********************************************************************/
function TrimRight(str)
{
varresultStr ="";
vari =0;

if (str+"" == "undefined" || str ==null)
return null;

str+= "";

if (str.length == 0)
resultStr ="";
else
{
i =str.length - 1;
while ((i >= 0)&& (str.charAt(i) == " "))
i--;

resultStr =str.substring(0, i + 1);
}

return resultStr;
}

/********************************************************************
**
*函数功能:判断输入的字符串是否为数字*
*输入参数:输入的对象*
*返回值:true-数字/false-非数字*
*调用函数:*
**
********************************************************************/
function isNumber(objName)
{
var strNumber = objName.value;
var intNumber;

if(Trim(strNumber) == "")
{
return true;
}

intNumber = parseInt(strNumber, 10);
if (isNaN(intNumber))
{
alert("请输入数字.");
objName.focus();
return false;
}
return true;
}

/********************************************************************
**
*函数功能:判断输入的字符串是否为数字*
*输入参数:输入的对象*
*返回值:true-数字/false-非数字*
*调用函数:*
**
********************************************************************/
function isFloat(objName)
{
var strFloat = objName.value;
var intFloat;

if(Trim(strFloat) == "")
{
return true;
}

intFloat = parseFloat(strFloat);
if (isNaN(intFloat))
{
alert("Please input a number.");
objName.focus();
return false;
}
return true;
}

}


/********************************************************************
**
*函数功能:判断输入的字符串是否为合法的时间*
*输入参数:输入的字符串*
*返回值:true-合法的时间/false-非法的时间*
*调用函数:*
**
********************************************************************/
function checkDate(strDate)
{
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var strSeparator = "-";
var err = 0;

strDateArray = strDate.split(strSeparator);

if (strDateArray.length != 3)
{
err = 1;
return false;
}
else
{
strYear = strDateArray[0];
strMonth = strDateArray[1];
strDay = strDateArray[2];
}

intday = parseInt(strDay, 10);
if (isNaN(intday))
{
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth))
{
        err = 3;
return false;
}
intYear = parseInt(strYear, 10);
if(strYear.length != 4)
{
return false;
}
if (isNaN(intYear))
{
err = 4;
return false;
}


if (intMonth>12 || intMonth<1)
{
err = 5;
return false;
}

if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1))
{
err = 6;
return false;
}

if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1))
{
err = 7;
return false;
}

if (intMonth == 2)
{
if (intday < 1)
{
err = 8;
return false;
}

if (LeapYear(intYear) == true)
{
if (intday > 29)
{
err = 9;
return false;
}
}
else
{
if (intday > 28)
{
err = 10;
return false;
}
}
}

return true;
}

/********************************************************************
**
*函数功能:判断是否为闰年*
*输入参数:输入的年*
*返回值:true-是/false-不是*
*调用函数:*
**
********************************************************************/
function LeapYear(intYear)
{
if (intYear % 100 == 0)
{
if (intYear % 400 == 0) { return true; }
}
else
{
if ((intYear % 4) == 0) { return true; }
}
return false;
}

/********************************************************************
*函数功能:*
********************************************************************/
function formDateCheck(year,month,day)
{
var strY = Trim(year);
var strM = Trim(month);
var strD = Trim(day);
var strDate = strY + "-" + strM + "-" + strD;
if((strY + strM + strD) != "")
{
if(!checkDate(strDate))
{
return false;
}
}
return true;
}

/********************************************************************
*函数功能:将form所有输入字段重置*
********************************************************************/
function setFormReset(objForm)
{
objForm.reset();
}
/********************************************************************
*函数功能:计算字符串的实际长度*
********************************************************************/

function strlen(str)
{
var len;
var i;
len = 0;
for (i=0;i<str.length;i++)
{
if (str.charCodeAt(i)>255) len+=2; else len++;
}
return len;
}
/********************************************************************
*函数功能:判断输入的字符串是不是中文*
********************************************************************/


function isCharsInBag (s, bag)
{
var i,c;
for (i = 0; i < s.length; i++)
{
c = s.charAt(i);//字符串s中的字符
if (bag.indexOf(c) > -1)
return c;
}
return "";
}

function ischinese(s)
{
var errorChar;
var badChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789><,[]{}?/+=|/'/":;~!#$%()`";
errorChar = isCharsInBag( s, badChar)
if (errorChar != "" )
{
//alert("请重新输入中文/n");
return false;
}

return true;
}

/********************************************************************
*函数功能:判断输入的字符串是不是英文*
********************************************************************/


function isCharsInBagEn (s, bag)
{
var i,c;
for (i = 0; i < s.length; i++)
{
c = s.charAt(i);//字符串s中的字符
if (bag.indexOf(c) <0)
return c;
}
return "";
}

function isenglish(s)
{
var errorChar;
var badChar = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
errorChar = isCharsInBagEn( s, badChar)
if (errorChar != "" )
{
//alert("请重新输入英文/n");
return false;
}

return true;
}
function isnum(s)
{
var errorChar;
var badChar = "0123456789";
errorChar = isCharsInBagEn( s, badChar)
if (errorChar != "" )
{
//alert("请重新输入英文/n");
return false;
}

return true;

 

自动显示TXT文本的内容
把如下代码加入<body>区域中
 <script language=vbscript>
Function bytes2BSTR(vIn)
    strReturn = ""
    For i = 1 To LenB(vIn)
        ThisCharCode = AscB(MidB(vIn,i,1))
        If ThisCharCode < &H80 Then
            strReturn = strReturn & Chr(ThisCharCode)
        Else
            NextCharCode = AscB(MidB(vIn,i+1,1))
            strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
            i = i + 1
        End If
    Next
    bytes2BSTR = strReturn
End Function
</script>
<script language="JavaScript">
var xmlUrl = new ActiveXObject('Microsoft.XMLHTTP');
xmlUrl.Open('GET','1.txt');
xmlUrl.Send();
setTimeout('alert(bytes2BSTR(xmlUrl.ResponseBody))',2000);
</script>

 


我也来帖几个:
//detect client browse version
function testNavigator(){
var message="系统检测到你的浏览器的版本比较低,建议你使用IE5.5以上的浏览器,否则有的功能可能不能正常使用.你可以到http://www.microsoft.com/china/免费获得IE的最新版本!";
var ua=navigator.userAgent;
var ie=false;
if(navigator.appName=="Microsoft Internet Explorer")
{
ie=true;
}
if(!ie){
alert(message);
return;
}
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))));
if(IEversion< 5.5){
alert(message);
return;
}
}

//detect client browse version
function testNavigator(){
var message="系统检测到你的浏览器的版本比较低,建议你使用IE5.5以上的浏览器,否则有的功能可能不能正常使用.你可以到http://www.microsoft.com/china/免费获得IE的最新版本!";
var ua=navigator.userAgent;
var ie=false;
if(navigator.appName=="Microsoft Internet Explorer")
{
ie=true;
}
if(!ie){
alert(message);
return;
}
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))));
if(IEversion< 5.5){
alert(message);
return;
}
}

//ensure current window is the top window
function checkTopWindow(){
if(window.top!=window && window.top!=null){
window.top.location=window.location;
}
}

//force close window
function closeWindow()
{
var ua=navigator.userAgent;
var ie=navigator.appName=="Microsoft Internet Explorer"?true:false;
if(ie)
{
var IEversion=parseFloat(ua.substring(ua.indexOf("MSIE ")+5,ua.indexOf(";",ua.indexOf("MSIE "))));
if(IEversion< 5.5)
{
var str  = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">'
str += '<param name="Command" value="Close"></object>';
document.body.insertAdjacentHTML("beforeEnd", str);
try
{
document.all.noTipClose.Click();
}
catch(e){}
}
else
{
window.opener =null;
window.close();
}
}
else
{
window.close()
}
}

//tirm string
function trim(s)
{
 return s.replace( /^/s*/, "" ).replace( //s*$/, "" );
}

//URI encode
function encode(content){
return encodeURI(content);
}

//URI decode
function decode(content){
return decodeURI(content);
}


这些都我的原创.
打开calendar选择,可以限制是否可选择当前日期后的日期.
//open a calendar window.
function openCalender(ctlValue){
var url="/twms/component/calendar.html";
var param="dialogHeight:200px;dialogWidth:400px;center:yes;status:no;help:no;scroll:yes;resizable:yes;";
var result=window.showModalDialog(url,ctlValue.value,param);
if(result!=null && result!="" && result!="undefined"){
ctlValue=result;
}
}

calendar.html
<html>
<head>
<title>选择日期:</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
 <link href="/twms/css/common.css" _fcksavedurl=""/twms/css/common.css"" type="text/css" rel="stylesheet">
<script language="JavaScript">
var limit=true;

function runNian(The_Year)
{
if ((The_Year%400==0) || ((The_Year%4==0) && (The_Year%100!=0)))
return true;
else
return false;
}

function getWeekday(The_Year,The_Month)
{
 
var Allday=0;
if (The_Year>2000)
{
 
for (i=2000 ;i<The_Year; i++)
{
if (runNian(i))
Allday += 366;
else
Allday += 365;
}

for (i=2; i<=The_Month; i++)
{
switch (i)
{
case 2 :
if (runNian(The_Year))
Allday += 29;
else
Allday += 28;
break;
case 3 : Allday += 31; break;
case 4 : Allday += 30; break;
case 5 : Allday += 31; break;
case 6 : Allday += 30; break;
case 7 : Allday += 31; break;
case 8 : Allday += 31; break;
case 9 : Allday += 30; break;
case 10 : Allday += 31; break;
case 11 : Allday += 30; break;
case 12 :  Allday += 31; break;
   
}
}
}
 
switch (The_Month)
{
case 1:return(Allday+6)%7;

case 2 :
if (runNian(The_Year))
return (Allday+1)%7;
else
return (Allday+2)%7;

case 3:return(Allday+6)%7;
case 4:return (Allday+7)%7;
case 5:return(Allday+6)%7;
case 6:return (Allday+7)%7;
case 7:return(Allday+6)%7;
case 8:return(Allday+6)%7;
case 9:return (Allday+7)%7;
case 10:return(Allday+6)%7;
case 11:return (Allday+7)%7;
case 12:return(Allday+6)%7;

}
}

function chooseDay(The_Year,The_Month,The_Day)
{
var Firstday;
Firstday = getWeekday(The_Year,The_Month);
showCalender(The_Year,The_Month,The_Day,Firstday);
}

function nextMonth(The_Year,The_Month)
{
if (The_Month==12)
chooseDay(The_Year+1,1,0);
else
chooseDay(The_Year,The_Month+1,0);
}

function prevMonth(The_Year,The_Month)
{
if (The_Month==1)
chooseDay(The_Year-1,12,0);
else
chooseDay(The_Year,The_Month-1,0);
}

function prevYear(The_Year,The_Month)
{
chooseDay(The_Year-1,The_Month,0);
}

function nextYear(The_Year,The_Month)
{
chooseDay(The_Year+1,The_Month,0);
}

function showCalender(The_Year,The_Month,The_Day,Firstday)
{
var Month_Day;
var ShowMonth;
var today= new Date();
//alert(today.getMonth());
 
switch (The_Month)
{
case 1 : ShowMonth = "一月"; Month_Day = 31; break;
case 2 :
ShowMonth = "二月";
if (runNian(The_Year))
Month_Day = 29;
else
Month_Day = 28;
break;
case 3 : ShowMonth = "三月"; Month_Day = 31; break;
case 4 : ShowMonth = "四月"; Month_Day = 30; break;
case 5 : ShowMonth = "五月"; Month_Day = 31; break;
case 6 : ShowMonth = "六月"; Month_Day = 30; break;
case 7 : ShowMonth = "七月"; Month_Day = 31; break;
case 8 : ShowMonth = "八月"; Month_Day = 31; break;
case 9 : ShowMonth = "九月"; Month_Day = 30; break;
case 10 : ShowMonth = "十月"; Month_Day = 31; break;
case 11 : ShowMonth = "十一月"; Month_Day = 30; break;
case 12 : ShowMonth = "十二月"; Month_Day = 31; break;
}
 
var tableTagBegin="<Table cellpadding=0 cellspacing=0 border=1 bordercolor=#999999 width=95% align=center valign=top>";
var blankNextTd="<td width=0>&gt;&gt;</td>";
var blankPrevTd="<td width=0>&lt;&lt;</td>";
var blankDayTd="<td align=center bgcolor=#CCCCCC>&nbsp;</td>";
var nextYearTd="<td width=0 onclick=nextYear("+The_Year+","+The_Month+")  style='cursor:hand'>&gt;&gt;</td>";
var prevYearTd="<td width=0 onclick=prevYear("+The_Year+","+The_Month+")  style='cursor:hand'>&lt;&lt;</td>";
var nextMonthTd="<td width=0 onclick=nextMonth("+The_Year+","+The_Month+")  style='cursor:hand'>&gt;&gt;</td>";
var prevMonthTd="<td width=0 onclick=prevMonth("+The_Year+","+The_Month+")  style='cursor:hand'>&lt;&lt;</td>";
var valueTdTagBegin="<td width=100 align=center colspan=5>";

var weekTextTr="<Tr align=center bgcolor=#999999>";
weekTextTr+="<td><strong><font color=#0000CC>日</font></strong>";
weekTextTr+="<td><strong><font color=#0000CC>一</font></strong>";
weekTextTr+="<td><strong><font color=#0000CC>二</font></strong>";
weekTextTr+="<td><strong><font color=#0000CC>三</font></strong>";
weekTextTr+="<td><strong><font color=#0000CC>四</font></strong>";
weekTextTr+="<td><strong><font color=#0000CC>五</font></strong>";
weekTextTr+="<td><strong><font color=#0000CC>六</font></strong>";
weekTextTr+="</Tr>";

var text=tableTagBegin;

text+="<Tr>"+prevYearTd+valueTdTagBegin+The_Year+"</td>";
if(limit && (The_Year>=today.getYear()) ){
text+=blankNextTd;
}
else{
text+=nextYearTd;
}
text+="</Tr>";

text+="<Tr>"+prevMonthTd+valueTdTagBegin+The_Month+"</td>";
if(limit && (The_Year>=today.getYear()) && (The_Month>=(today.getMonth()+1)) ){
text+=blankNextTd;
}
else{
text+=nextMonthTd;
}
text+="</Tr>"+weekTextTr;

text+="<Tr>";

for (var i=1; i<=Firstday; i++){
text+=blankDayTd;
}


for (var i=1; i<=Month_Day; i++)
{
var bgColor="";
if ( (The_Year==today.getYear()) && (The_Month==today.getMonth()+1) && (i==today.getDate()) )
{
bgColor = "#FFCCCC";
}
else
{
bgColor = "#CCCCCC";
}

if (The_Day==i)
{
bgColor = "#FFFFCC";
}

if(limit && (The_Year>=today.getYear()) && (The_Month>=(today.getMonth()+1)) && (i>today.getDate()))
{
text+="<td align=center bgcolor='#CCCCCC' >" + i + "</td>";
}
else
{
text+="<td align=center bgcolor=" + bgColor + " style='cursor:hand' onclick=getSelectedDay(" + The_Year + "," + The_Month + "," + i + ")>" + i + "</td>";
}

Firstday = (Firstday + 1)%7;
if ((Firstday==0) && (i!=Month_Day)) {
text += "</Tr><Tr>";
}
}

if (Firstday!=0)
{
for (var i=Firstday; i<7; i++)
{
text+=blankDayTd;
}

text+= "</Tr>";
}
 
text += "</Table>";
document.all.divContainer.innerHTML=text;
}

function getSelectedDay(The_Year,The_Month,The_Day){
window.returnValue=The_Year + "-" + format(The_Month) + "-" + format(The_Day);
//alert(window.returnValue);
window.close();
}

function format(i){
if(i<10){
return "0"+i;
}
else{
return i;
}
}

function init(){
var args=window.dialogArguments.split("-");
//alert(args);
var year=parseInt(args[0]);
var month=parseInt(args[1]);
var day=parseInt(args[2]);
var firstDay=getWeekday(year,month);
showCalender(year,month,day,firstDay);
}
</script>
</head>
<body style="text-align:center">
<div id="divContainer"/>
<script language=javascript>
init();
</script>
</body>
</html>

 

//parse the search string,then return a object.
//object info:
//--property:
//----result:a array contained a group of name/value item.the item is nested class.
//--method:
//----getNamedItem(name):find item by name.if not exists,return null;
//----appendItem(name,value):apppend an item into result tail;
//----removetItem(name):remove item which contained in result and named that name.
//----toString():override Object.toString();return a regular query string.
function parseQueryString(search){
var object=new Object();
object.getNamedItem=getNamedItem;
object.appendItem=appendItem;
object.removeItem=removeItem;
object.toString=toString;
object.result=new Array();

function parseItem(itemStr){
var arStr=itemStr.split("=");
var obj=new Object();
obj.name=arStr[0];
obj.value=arStr[1];
obj.toString=toString;
function toString(){
return obj.name+"="+obj.value;
}
return obj;
}

function appendItem(name,value){
var obj=parseItem(name+"="+value);
object.result[object.result.length]=obj;
}

function removeItem(name){
var j;
for(j=0;j<object.result.length;j++){
if(object.result[j].name==name){
object.result.replice(j,1);
}
}
}

function getNamedItem(name){
var j;
for(j=0;j<object.result.length;j++){
if(object.result[j].name==name){
return object.result[j];
}
}

return null;
}

function toString(){
var k;
var str="";
for(k=0;k<object.result.length;k++){
str+=object.result[k].toString()+"&";
}

return str.substring(0,str.length-1);
}


var items=search.split("&");
var i;
for(i=0;i<items.length;i++){
object.result[i]=parseItem(items[i]);
}

return object;
}

 

关闭窗体[无须修改][共1步]

====1、将以下代码加入HEML的<body></body>之间:

<script language="JavaScript">
function shutwin(){
window.close();
return;}
</script>
<a href="javascript:shutwin();">关闭本窗口</a>

 

检测系统信息

<script language="JavaScript" type="text/javascript">
<!--
var newline = "/r/r"
var now = new Date()
var millinow=now.getTime()/1000
var hours = now.getHours()
var minutes = now.getMinutes()
var seconds = now.getSeconds()
var yourLocation=""
now.setHours(now.getHours()+1)
var min=60*now.getUTCHours()+now.getUTCMinutes() + now.getUTCSeconds()/60;
var internetTime=(min/1.44)
internetTime="Internet Time: @"+Math.floor(internetTime)
var clock = "It's exactly "+hours+":"+minutes+":"+seconds+" hours" 
var browser = "You are using " + navigator.appName +" "+navigator.appVersion
yourLocation="You are probably living in "+yourLocation
var winwidth= window.screen.width
var winheight= window.screen.height
var screenresolution= "Screen resolution: "+window.screen.width+" x "+window.screen.height
var lastdoc = "You came from: "+document.referrer
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function Who(info){
var VisitorName = GetCookie('VisitorName')
if (VisitorName == null) {
VisitorName = "stranger";
SetCookie ('VisitorName', VisitorName, exp);
}
return VisitorName;
}
function When(info){
// When
var rightNow = new Date()
var WWHTime = 0;
WWHTime = GetCookie('WWhenH')
WWHTime = WWHTime * 1
var lastHereFormatting = new Date(WWHTime);  // Date-i-fy that number
var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) +
lastHereFormatting.getDate()
var lastHereInDateFormat = "" + lastHereFormatting;  // Gotta use substring functions
var dayOfWeek = lastHereInDateFormat.substring(0,3)
var dateMonth = lastHereInDateFormat.substring(4,11)
var timeOfDay = lastHereInDateFormat.substring(11,16)
var year = lastHereInDateFormat.substring(23,25)
var WWHText = dayOfWeek + ", " + dateMonth + " at " + timeOfDay // display
SetCookie ("WWhenH", rightNow.getTime(), exp)
return WWHText;
}
function Count(info){
var psj=0;
// How many times
var WWHCount = GetCookie('WWHCount')
if (WWHCount == null) {
WWHCount = 0;
}
else{
WWHCount++;
}
SetCookie ('WWHCount', WWHCount, exp);
return WWHCount;
}
function set(){
VisitorName = prompt("Who are you?");
SetCookie ('VisitorName', VisitorName, exp);
SetCookie ('WWHCount', 0, exp);
SetCookie ('WWhenH', 0, exp);
}
function getCookieVal (offset) { 
var endstr = document.cookie.indexOf (";", offset); 
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "="; 
var alen = arg.length;
var clen = document.cookie.length; 
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length; 
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null; 
var domain = (argc > 4) ? argv[4] : null; 
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) + 
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date(); 
exp.setTime (exp.getTime() - 1); 
// This cookie is history
var cval = GetCookie (name); 
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var countvisits="You've been here " + Count() + " time(s). Last time was " + When() +"."
if (navigator.javaEnabled()) {
var javaenabled="Your browser is able to run java-applets";
}
else {
var javaenabled="Your browser is not able to run java-applets";
}
function showAlert() {
var later = new Date()
var millilater=later.getTime()/1000
var loadTime=(Math.floor((millilater-millinow)*100))/100
var loadTimeResult= "It took you "+loadTime+" seconds to load this page"
var babiesborn=Math.ceil(loadTime*4.18)
var babiesbornresult="While this page was loading "+babiesborn+" babies have been born"
if (babiesborn==1){babiesbornresult="While this page was loading "+babiesborn+" baby has been born"}
alert
(newline+newline+browser+newline+clock+newline+loadTimeResult+newline+internetTime+newline+screenresolution+newline+lastdoc+newline+countvisits+newline+javaenabled+newline+babiesbornresult+newline+newline)
}
// --></script>
<body onLoad="showAlert()">


密码保护:

将以下代码加入HEML的<body></body>之间:
<script LANGUAGE="JAVASCRIPT">
<!--
loopy()
function loopy() {
var sWord =""
while (sWord != "welcome") { //改为您的密码!
sWord = prompt("请输入正确的密码!现在密码为:welcome")
}
alert("AH...欢迎光临!")
}
//-->
</script>


 

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. oncopy="return false;" oncut="return false;" 防止复制

5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标

6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标

7. <input style="ime-mode:-Disabled"> 关闭输入法

8. 永远都会带着框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// --></script>

9. 防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>

10. 网页将不能被另存为
<noscript><iframe src=*.html></iframe></noscript>

11. <input type=button value=查看网页源代码
onclick="window.location = `view-source:`+ http://www.51js.com/`";>

12.删除时确认
<a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删

除</a>

13. 取得控件的绝对位置
//javascript
<script language="javascript">
function getIE(E){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"/nleft="+l);
}
</script>

//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>

14. 光标是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart(`character`,e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">

15. 判断上一页的来源
javascript:
document.referrer

16. 最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>

<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=关闭 onclick=hh3.Click()>
本例适用于IE

17.屏蔽功能键Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift键!"; //可以换成ALT CTRL
}
document.onkeydown=look;
</script>

18. 网页不会被缓存
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">

19.怎样让表单没有凹凸感?
<input type=text style="border:1 solid #000000">

<input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:

1 solid #000000"></textarea>

20.<div><span>&<layer>的区别?
<div>(division)用来定义大段的页面元素,会产生转行
<span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
<layer>是ns的标记,ie不支持,相当于<div>

21.让弹出窗口总是在最上面:
<body onblur="this.focus();">

22.不要滚动条?
让竖条没有:
<body style=`overflow:-Scroll;overflow-y:hidden`>
</body>
让横条没有:
<body style=`overflow:-Scroll;overflow-x:hidden`>
</body>
两个都去掉?更简单了
<body scroll="no">
</body>

23.怎样去掉图片链接点击后,图片周围的虚线?
<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>

24.电子邮件处理提交表单
<form name="form1" method="post" action="mailtosheepish.gif***@***.com" enctype="text/plain">
<input type=submit>
</form>

25.在打开的子窗口刷新父窗口的代码里如何写?
window.opener.location.reload()

26.如何设定打开页面的大小
<body onload="top.resizeTo(300,200);">
打开页面的位置<body onload="top.moveBy(300,200);">

27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
<style>
body
{background-image:url(logo.gif); background-repeat:no-repeat;

background-position:center;background-attachment: fixed}
</style>

28. 检查一段字符串是否全由数字组成
<script language="javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"
alert(checkNum("123214214a1"
// --></script>

29. 获得一个窗口的大小
document.body.clientWidth; document.body.clientHeight

30. 怎么判断是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
else alert("全是字符";

31.TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>

32. 日期减去天数等于第二个日期
<script language=javascript>
function cc(dd,dadd)
{
//可以加上错误处理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(A)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日"
}
cc("12/23/2002",2)
</script>

33. 选择了哪一个Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" onclick="checkme()">
</BODY></HTML>

34.脚本永不出错
<SCRIPT LANGUAGE="javascript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>

35.ENTER键可以让光标移到下一个输入框
<input onkeydown="if(event.keyCode==13)event.keyCode=9">

36. 检测某个网站的链接速度:
把如下代码加入<body>区域中:
<script language=javascript>
tim=1
setInterval("tim++",100)
b=1

var autourl=new Array()
autourl[1]="http://www.njcatv.net/";
autourl[2]="javacool.3322.net"
autourl[3]="http://www.sina.com.cn/";
autourl[4]="http://www.nuaa.edu.cn/";
autourl[5]="http://www.cctv.com/";

function butt(){
document.write("<form name=autof>"
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text

name=url"+i+" size=40> =》<input type=button value=GO

onclick=window.open(this.form.url"+i+".value)><br>"
document.write("<input type=submit value=刷新></form>"
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="链接超时"}
else
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
b++
}
function run(){for(var i=1;i<autourl.length;i++)document.write("<img

src=http://"+autourl+"/"+Math.random()+" width=1 height=1

onerror=auto(http://";+autourl+"`)>"}
run()</script>

37. 各种样式的光标
auto :标准光标
default :标准箭头
hand :手形光标
wait :等待光标
text :I形光标
vertical-text :水平I形光标
no-drop :不可拖动光标
not-allowed :无效光标
help :?帮助光标
all-scroll :三角方向标
move :移动标
crosshair :十字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize

38.页面进入和退出的特效
进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
这个是页面被载入和调出时的一些特效。Duration表示特效的持续时间,以秒为单位。Transition表示使

用哪种特效,取值为1-23:
  0 矩形缩小
  1 矩形扩大
  2 圆形缩小
  3 圆形扩大
  4 下到上刷新
  5 上到下刷新
  6 左到右刷新
  7 右到左刷新
  8 竖百叶窗
  9 横百叶窗
  10 错位横百叶窗
  11 错位竖百叶窗
  12 点扩散
  13 左右到中间刷新
  14 中间到左右刷新
  15 中间到上下
  16 上下到中间
  17 右下到左上
  18 右上到左下
  19 左上到右下
  20 左下到右上
  21 横条
  22 竖条
  23 以上22种随机选择一种

39.在规定时间内跳转
<META http-equiv=V="REFRESH" content="5;URL=http://www.51js.com">

40.网页是否被检索
<meta name="ROBOTS" content="属性值">
  其中属性值有以下一些:
  属性值为"all": 文件将被检索,且页上链接可被查询;
  属性值为"none": 文件不被检索,而且不查询页上的链接;
  属性值为"index": 文件将被检索;
  属性值为"follow": 查询页上的链接;
  属性值为"noindex": 文件不检索,但可被查询链接;
  属性值为"nofollow": 文件不被检索,但可查询页上的链接。

41.变换网页的鼠标光标
<BODY style="CURSOR: url(http://203.73.125.205/~liangmi2/farmfrog01.cur`)">

42.怎样实现在任务栏显示小图标的效果? (要使用绝对地址)
有些站点,访问时会在地址栏地址前显出小图标,添加到收藏夹后也在收藏栏中显示图标,
这样很好的与其它站点有了区别。
要达到这个效果,先需做出这个图标文件,图像为16*16像素,不要超过16色。文件格式为ico,然后上传至你的网站。
然后,在需要的页面中,加上以下html语句到文件的<head>和</head>之间(假设以上ico文件的地址http://happyisland.126.com/icon.ico)。
<link REL="SHORTCUT ICON"href="http:///happyisland.126.com/icon.ico";>
如果访问者的浏览器是IE5.0,就不需加任何代码,只要将图标文件上传到网站的根目录下即可。
1,META标签里的代码是什么意思?
<META>是放于<HEAD>与</HEAD>之间的标记.以下是我总结它在网页中最常见的几种。
<meta name="Keywords" content="图片, 新闻, 音乐, 软件">
该网页的关键字,作用于搜索引擎的登录,事实上它在现在的网站中并没什么用。
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
设定这是 HTML 文件及其编码语系,简体中文网页使用charset=gb2312,繁体中文使用charset=big5,或者不设编码也可,纯英文网页建议使用 iso-8859-1。
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
这只表示该网页由什么编辑器写的。
<meta http-equiv="refresh" content="10; url=http://www.hkiwc.com">
这行较为实用,能于预定秒数内自动转到指定网址。原代码中 10 表示 10秒。

2,怎么改变滚动条的颜色,只有ie5.5版本以上才能支持。
这是使用CSS语言,在次说明一下,它和我的浏览器版本有一定的关系。
scrollbar-arrow-color:上下按钮上三角箭头的颜色。
scrollbar-base-color:滚动条的基本颜色。
scrollbar-dark-shadow-color:立体滚动条强阴影的颜色
scrollbar-face-color:立体滚动条凸出部分的颜色
scrollbar-highlight-color:滚动条空白部分的颜色
scrollbar-shadow-color立体滚动条阴影的颜色。
scrollbar-track-color:#99CC33;
scrollbar-3dlight-color:#A8CBF1;
代码如下:
<style>
<!--
BODY {
scrollbar-face-color:#99CC33;//(立体滚动条凸出部分的颜色)
scrollbar-highlight-color:#A8CBF1;//(滚动条空白部分的颜色)
scrollbar-shadow-color:#A8CBF1;//(立体滚动条阴影的颜色)
scrollbar-arrow-color:#FF9966;//(上下按钮上三角箭头的颜色)
scrollbar-base-color:#A8CBF1; //(滚动条的基本颜色)
scrollbar-darkshadow-color:#A8CBF1; //(立体滚动条强阴影的颜色)
scrollbar-track-color:#99CC33;
scrollbar-3dlight-color:#A8CBF1;
}
-->
</style>
在这我补充几点:
1.让浏览器窗口永远都不出现滚动条。
<body style="overflow-x:hidden;overflow-y:hidden">或<body style="overflow:hidden"> 或<body scroll=no>
2,没有水平滚动条
<body style="overflow-x:hidden">
3,没有垂直滚动条
<body style="overflow-y:hidden">

3,如何给图片抖动怎做的.
<SCRIPT language=javascript1.2>
<!--
var rector=2
var stopit=0
var a=1
var count=0
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1||count==100)
return
count++
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
count=0
which.style.left=0
which.style.top=0
}
//-->
</SCRIPT>
<style>.shakeimage {POSITION: relative}
</style>
<img src="图片的路径" onmouseout=stoprattle(this) onmouseover=init(this);rattleimage() class=shakeimage>

4,在DW如何给水平线加颜色。
在DW中没有此项设置,你只能在HTML中加入代码:<hr color=red noshade>按F12的预览在能看到。由于在NC中不支持<hr>的COLOR属性,所以在DW中没有此项设置。
   
5,如何在网页中实现flash的全屏播放?
只要在调用swf文件的HTML中将WIDTH和HEIGHT的参数设为100%即可,当然也可以在Flash导出HTML文件的设置中进行设置,方法是:打开File菜单;选Publish Settings弹出导出设置对话框;在HTML标签下的Dimensions选项,下拉后选中Percent(百分比),并在WIDTH 和HEIGHT框中填100.就行了。

6,为什么我在DW中插入的Flash动画缺看不找!
如果你没有正确地安装Dreamweaver和Flash,那么在你预览的时候,Dreamweaver会提示你缺少播放的插件,请你按装InstallAXFlash.exe 并从新启动计算机。现在IE6已经捆绑这个程序。

7,在Flash中,如果屏蔽鼠标右键?FS命令都是什么意思?
fscommand ("fullscreen", "true/false";(全屏设置,TRUE开,FALSE关)
fscommand ("showmenu", "true/false";(右键菜单设置,TRUE显示,FALSE不显示)
fscommand ("allowscale", "true/false";(缩放设置,TRUE自由缩放,FALSE调整画面不影响影片本身的尺寸)
fscommand ("trapallkeys", "true/false";(快捷键设置,TRUE快捷键开,FALSE快捷键关)
fscommand ("exec";(EXE程序调用)
fscommand ("quit";(退出关闭窗口)

8,Flash中什么是隐形按钮。
利用button中的hit帧来制作只有感应区域而完全透明的按钮。

9,如何给Flash动画做链接。
Dreamweaver是不能给Flash制作链接的,只能在Flash中用geturl()加链接,然后再插入Dreamweaver中。

10,DW中的层的技巧。
层是可以嵌套的,我个人给大家一个技巧,在层面板中按住CTRL再拖放层到你想去成为其子层的地方就行了,我认为这是最简单直观的方法了。

11,如何改变鼠标的形状?
在Dreamweaver4中CSS样式面板:
按CTR +SHIFT+E--出现样式表对话框,点击NEW,出现编辑对话框,在左边最后一项extensions-cursor 选择你要改的指针形式就可以了,然后把你要想改变的地方运用样式表,如果整页都有在<body bgcolor="#003063" text="#ffffff" id= all>中加入就行了。
<span style="cursor:X`>样例</span>
这里选择(文本)作为对象,还可以自己改为其他的,如link等。
x 可以等于=hand(手形)、crosshair(十字)、text(文本光标)、wait(顾名思义啦)、default(默认效果)、help(问号)、e-size(向右箭头)、ne-resize(向右上的箭头)、nw-resize(向左上的箭头)、w-resize(向左的箭头)、sw- resize(左下箭头)、s-resize(向下箭头)、se-resize(向右下箭头)、auto(系统自动给出效果)。

12,用CSS做邮票,看看吧!
<input type=button value=我象不象邮票? style="height:80px;border:2px dashed #cccccc">

13,经常上网的朋友可能会到过这样一些网站,一进入首页立刻会弹出一个窗口,怎么做呢!
这javascript代码即可实现,摘录蓝色论坛。
【1、最基本的弹出窗口代码】
其实代码非常简单:
<SCRIPT LANGUAGE="javascript">
<!--
window.open (`page.html`)
-->
</SCRIPT>
因为着是一段javascripts代码,所以它们应该放在<SCRIPT LANGUAGE="javascript">标签和< /script>之间。<!-- 和 -->是对一些版本低的浏览器起作用,在这些老浏览器中不会将标签中的代码作为文本显示出来。要养成这个好习惯啊。
window.open (`page.html`) 用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。用单引号和双引号都可以,只是不要混用。
这一段代码可以加入HTML的任意位置,<head>和</head>之间可以,<body bgcolor= "#003063" text="#ffffff" id=all>间</body>也可以,越前越早执行,尤其是页面代码长,又想使页面早点弹出就尽量往前放。
【2、经过设置后的弹出窗口】
下面再说一说弹出窗口的设置。只要再往上面的代码中加一点东西就可以了。
我们来定制这个弹出的窗口的外观,尺寸大小,弹出的位置以适应该页面的具体情况。
<SCRIPT LANGUAGE="javascript">
<!--
window.open (`page.html`, `newwindow`, `height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no`)
//写成一行
-->
</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="javascript"> js脚本开始;
window.open 弹出新窗口的命令;
`page.html` 弹出窗口的文件名;
`newwindow` 弹出窗口的名字(不是文件名),非必须,可用空``代替;
height=100 窗口高度;
width=400 窗口宽度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏。
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</SCRIPT> js脚本结束
【3、用函数控制弹出窗口】
下面是一个完整的代码。
<html>
<head>
<script LANGUAGE="javascript">
<!--
function openwin() { window.open ("page.html", "newwindow", "height=100, width=400, toolbar=
no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//写成一行
}
//-->
</script>
</head>
<body onload="openwin()">
…任意的页面内容…
</body>
</html>
这里定义了一个函数openwin(),函数内容就是打开一个窗口。在调用它之前没有任何用途。
怎么调用呢?
方法一:<body onload="openwin()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwin()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:
<a href="#" onclick="openwin()">打开一个窗口</a>
注意:使用的“#”是虚连接。
方法四:用一个按钮调用:
<input type="button" onclick="openwin()" value="打开窗口">

14,没有用表格写的,让大家随便看看,没什么。
<html>
<head>
<title>江南荷花扇面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.font1 { font-size: 12px; color: #999999; text-decoration: none}
a { font-size: 12px; color: #999999; text-decoration: none}
a:hover { font-size: 12px; color: #000000; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="font1" style="writing-mode=tb-rl;height:200px" width=300>
<p>盛夏      尚 涛 
<p><a href="index.htm">一夜露痕黄粉香 袁运甫 </a>
<p>瑶池昨夜新凉  王金岭
<p>一朵白莲随意开 吴冠南
<p>新雨迎秋欲满塘 齐辛民
<p>十里荷香    齐辛民
<p>濯清莲而不妖  卢世曙
</div>
</body>
</html>

15,IE6已支持自定义cursor!
语法格式 cursor:url(图标) //cur或是ani文件.
cur就是WINDOWS中的光标(cursor)文件,光标文件与图标(ICON)文件除了文件头有一个位置的值不同外,实际是一样的。
ani是WINDOWS中的动画光标(图标)文件。
<style type="text/css">
<!--
.unnamed1 { cursor:url(arrow2c.cur)}
-->
</style>

16,用marquee做的滚动字幕.这也我刚看到论坛的朋友在问。
语法:
align=# | top | middle| bottom //对齐方式)
BEHAVIOR=ALTERNATE | SCROLL | SLIDE //移动的方式
BGCOLOR=color//底色区域颜色
DIRECTION=DOWN | LEFT | RIGHT | UP //移动的方向
Loop=n //循环次数(默认是循环不止)
Scrolldelay=milliseconds//延时
height=# width=# //区域面积
hspace=# vspace=# //空白区域
scrollamount=# //移动的速度
<marquee align=top behavior=ALTERNATE BGCOLOR=#000000 height=60 width=433 scrollamount=5></marquee>

17,在FLASH5中也存在一些字体,打散后变成一团的事是为什么?有解决的办法吗。
这是大家很常见的问题!可能是对字库支持的不好!我个是做成透明的gif图片格式,然后倒入。

18,flash的网页里“加入收藏夹”功能怎么实现?
在as中加getUrl("java script:window.external.addFavorite(http://skydesigner.51.net`,`我的工作室`)"

19,在Flash中,文本的动态属性和输入属性的区别。
input text在运行时可被用户或程序改变其值。
ynamic text仅允许被程序修改。

20,怎样在IE中调用Dreamweaver进行编辑.
相信很多在使用WinME或Window2000的朋友,会遇见是个问题。很简单,把我们笔记本程序打开,保存为一个 *.reg 文件。双击它将信息添加到注册表即可。
REGEDIT4
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver]
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver/shell]
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver/shell/edit]
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver/shell/edit/command]
@="/"c://Program Files//Macromedia//Dreamweaver 4//dreamweaver.exe/" /"%1/""

21,设置表格虚线。
方法一:作一个1X2的图。半黑半白,再利用表格作成线。
方法二:在css里面设,要IE5。5才支持这种效果。
style="BORDER-LEFT: #000000 1PX DASHED; BORDER-RIGHT: #000000 1PX DASHED; BORDER-TOP: #000000 1PX DASHED; BORDER-BOTTOM: #000000 1PX DASHED"

22,看看在网页中调用HHCtrl控件效果。
代码如下:
<object id="HHC" type="application/x -oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"></object> <script>HHC.TextPopup("哈哈,大家好,我是闪梦!","",50,5,128255,346751);< /script>

22,如何让一张图片有浅到深的渐变。
<SCRIPT language=javascript1.2>
<!--
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=40
}
function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
</script>
<img onmouseout=low(this) onmouseover=high(this) style="FILTER: alpha(opacity=40)"src="logo.gif" >

23,双击鼠标左键来滚动背景,单击停止。
<SCRIPT language=javascript>
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",16);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</SCRIPT>

24,如何在同一页面设置不同文字链接效果的样式.
代码如下:
<HTML><HEAD><TITLE>如何在同一页面设置不同文字链接效果的样式</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a:hover { font-size: 9pt; color: #FF0000; text-decoration: underline}
a:link { font-size: 9pt; color: #006699; text-decoration: underline}
a:visited { font-size: 9pt; color: #006699; text-decoration: underline}
a:active { font-size: 9pt; color: #FF0000; text-decoration: none}
a.r1:hover { font-size: 9pt; color: #FF0000; text-decoration: underline overline}
a.r1:link { font-size: 9pt; color: #000000; text-decoration: underline overline}
a.r1:visited { font-size: 9pt; color: #99CC00; text-decoration: underline overline}
a.r1:active { font-size: 9pt; color: #000000; text-decoration: underline overline}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<a href="#">下划线链接 </a>
<p></p>
<a href="#" class="r1">双下划线链接</a>
</BODY>
</HTML>
补充说明:
a:hover 表示鼠标划过时的样式.
a:link 表示链接的样式.
a:active 表示当前活动连接的样式.
a:visited 表示已经访问过的连接的样式.

25, 用CSS给文字加入阴影效果和文字描边效果。
.glow{FONT-SIZE: 9pt; FILTER: Glow(Color=#000000, Strength=1)}
//文字描边效果
.shadow  {FONT-SIZE: 9pt; FILTER: DropShadow(OffX=1, OffY=1, DropShadow(OffX=1, OffY =1, color:#111111); COLOR: #ffffff; FONT-FAMILY: "宋体"}
//加入阴影效果
补充说明:
  这两种滤镜要想实现效果,必须加在如:<td class=glow或shadow ><div>xxxxxxxxx</div></td>上
,并且要留有足够的空间能够显示阴影或描边,否则会出现半截的阴影或描边现象。

26,如何给做带颜色的下拉菜单。
<select style="FONT-SIZE: 10px; COLOR: #ffffff; FONT-FAMILY: Verdana;BACKGROUND-COLOR: #ff6600;" size=1 >
<option selected>:: Dreamweaver4 ::</option>
<option>::Flash5::</option>
<option>::Firewoks4::</option>
</select>

27,关于DW4的表格中的亮边框和暗边框问题。
在DW4的表格面板中并没有亮边框和暗边框的属性设置,因为NC不支持,只有你在代码中添加了。
bordercolorlight="#999999" bordercolordark="#000000"
  你也可以用Css定义一个class。例如:
<style>
.bordercolor { bordercolorlight: #999999; bordercolordark: #000000 }
</style>
  然后在要加效果的表格里加上<table class="bordercolor">

28,自动显示主页最后更新日期.
<script>
document.write("最后更新日期:"+document.lastModified+""
</script>

29,如何让滚动条出现在左边?
我想居然在论坛中有人发表了这段代码,很有意思,它的确照顾一些左撇子,呵呵!
<html dir="rtl">
<body bgcolor="#000000" text="#FFFFFF">
<table height=18 width=212 align=center bgcolor=#FFFFFF dir="ltr" cellspacing="1"  cellpadding="0">
<tr>
<td bgcolor="#FF0000" >是不是你的滚动条在左边啊</td>
</tr>
</table>
</body>
</html>

30,如何加入网址前面的小图标?
  首先,您必须了解所谓的图标(Icon)是一种特殊的图形文件格式,它是以 .ico 作为扩展名。你可用在网上找一个制作图标软件,它具有特有的规格:图标的大小为 16 * 16(以像素为单位);颜色不得超过 16 色。 在该网页文件的 HEAD 部分加入下面的内容:< LINK REL="SHORTCUT ICON" HREF=" http://skydesigner.51.net/图标文件名">,并放在该网页的根目录下。

31,在800*600显示器中,如何不让网页水平出现滚动条!
设至<body leftmargin="0" topmargin="0">,网页中的表格宽度为778。

32,关于<!DOTYPE>的说明解释。
在网页中,经常会看到〈!DOCTYPE HTML PUBLIC`-//W3C//DTD HTML 4.01//EN`>,是声明HTML文件的版本信息。

33, 用图片来关闭窗体.
<A href="java script:window.close()"><IMG height=20 width=20 alt="关闭窗口" src="close.gif" border=0></A>
补充说明:如何使用了ACTIVEX!,不再警告窗口?
<html>
<head>
<object id=closes type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close"></object>
</head>
<body bgcolor="#003063" text="#ffffff" id=all> <a href="#" onclick="closes.Click();">关闭窗口无提示</a>
</body>
</html>

34,禁止鼠标右键查看网页源代码。
<SCRIPT language=javascript>
function click()
{if (event.button==2) {alert(`你好,欢迎光临!`) }}
document.onmousedown=click
</SCRIPT>
补充说明:
鼠标完全被封锁,可以屏蔽鼠标右键和网页文字。
< body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">

35,通过按钮来查看网页源代码。
<input type="BUTTON" value="查看源代码" onClick= `window.location = "view-source:" + window.location.href` name="BUTTON">

36,怎么用文字联结实现按钮的SUBMIT功能?
<a href="#" onclick="formname.submit()">OK</a>
这段文字要放在form里。formname是这里要写在form中的name,<form name=form111>那么就应该是form111.submit()

37,如何做一个空链接?
加#

38,利用<IFRAME>来给网页中插入网页。
  经常我看到很多网页中又有一个网页,还以为是用了框架,其实不然,是用了<IFRAME>,它只适用于IE,NS可是不支持< IFRAME>的,但围着的字句只有在浏览器不支援 iframe 标记时才会显示,如<noframes>一样,可以放些提醒字句之类的话。
你注意啊!下面请和我学习它的用法。
分析代码:<iframe src="iframe.html" name ="test" align="MIDDLE" width="300" height="100" marginwidth="1" marginheight="1" frameborder="1" scrolling="Yes"> </iframe>
  src="iframe.html"
  用来显示<IFRAME>中的网页来源,必要加上相对或绝对路径。
  name="test"
  这是连结标记的 target 参数所需要的。
  align="MIDDLE"
  可选值为 left, right, top, middle, bottom,作用不大 。
  width="300" height="100"
  框窗的宽及长,以 pixels 为单位。
  marginwidth="1" marginheight="1"
  该插入的文件与框边所保留的空间。
  frameborder="1"
  使用 1 表示显示边框, 0 则不显示。(可以是 yes 或 no)
  scrolling="Yes"
  使用 Yes 表示容许卷动(内定), No 则不容许卷动。

39,请问<tbody>的用法?
tbody用法据说是加强对表格的控制能力的.例如:
 <table><tbody>……..</tbody></table>
  tbody代码如果不是你用手写的话,只有在你用IE5打开一个网页的时候, 把它另存为
一下,你的另存为的文件在表格中就会生成tbody代码。(即便你的表格根本就没有
tbody代码,IE5另存为的时候也会给你生成)。

40,Alt和Title都是提示性语言标签,请注意它们之间的区别。
  在我们浏览网页时,当鼠标停留在图片对象或文字链接上时,在鼠标的右下角有时会出现一个提示信息框。对目标进行一定的注释说明。在一些场合,它的作用是很重要的。
alt 用来给图片来提示的。Title用来给链接文字或普通文字提示的。
用法如下:
   <p Title="给链接文字提示">文字</p>
   <a href="#" Title="给链接文字提示">文字</a>
   <img src="图片.gif" alt="给图片提示">
补充知识:<TITLE><ALT>里面如何多行换行?在源代码里Enter回车。
<a href="#" Title="个人简历
姓名:张培
网名:我是闪梦
性别:男的,不是女的。
爱好:网页制作,软件开发">个人简历</a>
例如:个人简历

41, 用javascript代码来实现闪烁按钮。
<body>
<form method="POST" action="--WEBBOT-SELF--">
<input type="button" name=SUB value="闪烁" id=flashit style="BORDER: 1px solid ;BACKGROUND-COLOR: #FFFFFF">
</form>
<script>
if (document.all&&document.all.flashit)
{
var flashelement=document.all.flashit
if (flashelement.length==null)
flashelement[0]=document.all.flashit
function changecolor(which)
{
if (flashelement[which].style.color==`#800000`)
flashelement[which].style.color="#0063A4"
else
flashelement[which].style.color="#800000"
}
if (flashelement.length==null)
setInterval("changecolor(0)",1000)
else
for (i=0;i<flashelement.length;i++)
{
var tempvariable=`setInterval("changecolor(`+i+`)",`+`1000)`
eval(tempvariable)
}
}
</script>
</body>

42,CSS给图片定义颜色边框。
img { border: 1px solid red}

43,在DW中如何使插入的FLASH透明。
方法一:选中swf,打开原代码窗口,在</object>前输入:<param name="wmode" value="transparent">
方法二:在Flash中的Flie→Publist Settings→HTML→Window Mode选择transparent

44,在DW编辑文本中,如何输入一个空格呢?
输入空格的问题,在DW似乎已成了一个老生常谈的问题。通过将输入法调整到全角模式就可以避免了。本以人工智能ABC为例.按Shift+Space切换到全角状态。

45,为何我的DW中图形显示不正常。
第一种:可能是因为你定义并正在使用一个site,而你的HTML文件或者图片不在这个site包含的区域之内,因此dreamweaver使用file协议来
描述图象的绝对路径,可惜IE不支持src中使用file协议,所以图象就显示不出来了。
第二种:可能是放图片的文件夹或图片名为中文,也显示不到网页中去。

46,如何在本地机器上测试flash影片的loading?
我想这可能是很多人在问的题了,其实很简单,在Test时,选选View->Show Streaming就可以看到了。

47,在网页中做出一根竖的线有几种办法.
第一种方法:用一个像素图的办法!
如果你用Dreamwever的Edit→Preferences…→Layout View中的Spacer Image给你创建了一个缺省名为:spacer.gif的一个像素图文件 。
代码中:
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000" height="200" ><img src="spacer.gif" width="1" height="1"></td>
</tr>
</table>
第二种方法:用表格填颜色的办法!把<td> </td>中的 删掉 .
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000" height="200" width="1"></td>
</tr>
</table>
第三种方法:用水平条。
<hr color="red" width="1" size="100%">

48, 关于鼠标拖动,改变层大小。──看看微软的做法.
<script>
document.execCommand("2D-position",false,true);
</script>
<DIV contentEditable=true>
<DIV style="WIDTH: 300px; POSITION: absolute; HEIGHT: 100px; BACKGROUND-COLOR: red">移动层</DIV>
</DIV>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. oncopy="return false;" oncut="return false;" 防止复制

5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标

6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标

7. <input style="ime-mode:-Disabled"> 关闭输入法

8. 永远都会带着框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// --></script>

9. 防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>

10. 网页将不能被另存为
<noscript><iframe src=*.html></iframe></noscript>

11. <input type=button value=查看网页源代码
onclick="window.location = `view-source:`+ http://www.51js.com/`";>

12.删除时确认
<a href=`javascript:if(confirm("确实要删除吗?"location="boos.asp?&areyou=删除&page=1"`>删

除</a>

13. 取得控件的绝对位置
//javascript
<script language="javascript">
function getIE(E){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"/nleft="+l);
}
</script>

//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>

14. 光标是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart(`character`,e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">

15. 判断上一页的来源
javascript:
document.referrer

16. 最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>

<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=关闭 onclick=hh3.Click()>
本例适用于IE

17.屏蔽功能键Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift键!"; //可以换成ALT CTRL
}
document.onkeydown=look;
</script>

18. 网页不会被缓存
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">

19.怎样让表单没有凹凸感?
<input type=text style="border:1 solid #000000">

<input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:

1 solid #000000"></textarea>

20.<div><span>&<layer>的区别?
<div>(division)用来定义大段的页面元素,会产生转行
<span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
<layer>是ns的标记,ie不支持,相当于<div>

21.让弹出窗口总是在最上面:
<body onblur="this.focus();">

22.不要滚动条?
让竖条没有:
<body style=`overflow:-Scroll;overflow-y:hidden`>
</body>
让横条没有:
<body style=`overflow:-Scroll;overflow-x:hidden`>
</body>
两个都去掉?更简单了
<body scroll="no">
</body>

23.怎样去掉图片链接点击后,图片周围的虚线?
<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>

24.电子邮件处理提交表单
<form name="form1" method="post" action="mailtosheepish.gif***@***.com" enctype="text/plain">
<input type=submit>
</form>

25.在打开的子窗口刷新父窗口的代码里如何写?
window.opener.location.reload()

26.如何设定打开页面的大小
<body onload="top.resizeTo(300,200);">
打开页面的位置<body onload="top.moveBy(300,200);">

27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
<style>
body
{background-image:url(logo.gif); background-repeat:no-repeat;

background-position:center;background-attachment: fixed}
</style>

28. 检查一段字符串是否全由数字组成
<script language="javascript"><!--
function checkNum(str){return str.match(//D/)==null}
alert(checkNum("1232142141"
alert(checkNum("123214214a1"
// --></script>

29. 获得一个窗口的大小
document.body.clientWidth; document.body.clientHeight

30. 怎么判断是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有汉字";
else alert("全是字符";

31.TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>

32. 日期减去天数等于第二个日期
<script language=javascript>
function cc(dd,dadd)
{
//可以加上错误处理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(A)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日"
}
cc("12/23/2002",2)
</script>

33. 选择了哪一个Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" onclick="checkme()">
</BODY></HTML>

34.脚本永不出错
<SCRIPT LANGUAGE="javascript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>

35.ENTER键可以让光标移到下一个输入框
<input onkeydown="if(event.keyCode==13)event.keyCode=9">

36. 检测某个网站的链接速度:
把如下代码加入<body>区域中:
<script language=javascript>
tim=1
setInterval("tim++",100)
b=1

var autourl=new Array()
autourl[1]="http://www.njcatv.net/";
autourl[2]="javacool.3322.net"
autourl[3]="http://www.sina.com.cn/";
autourl[4]="http://www.nuaa.edu.cn/";
autourl[5]="http://www.cctv.com/";

function butt(){
document.write("<form name=autof>"
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text

name=url"+i+" size=40> =》<input type=button value=GO

onclick=window.open(this.form.url"+i+".value)><br>"
document.write("<input type=submit value=刷新></form>"
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{document.forms[0]["txt"+b].value="链接超时"}
else
{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
b++
}
function run(){for(var i=1;i<autourl.length;i++)document.write("<img

src=http://"+autourl+"/"+Math.random()+" width=1 height=1

onerror=auto(http://";+autourl+"`)>"}
run()</script>

37. 各种样式的光标
auto :标准光标
default :标准箭头
hand :手形光标
wait :等待光标
text :I形光标
vertical-text :水平I形光标
no-drop :不可拖动光标
not-allowed :无效光标
help :?帮助光标
all-scroll :三角方向标
move :移动标
crosshair :十字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize

38.页面进入和退出的特效
进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
这个是页面被载入和调出时的一些特效。Duration表示特效的持续时间,以秒为单位。Transition表示使

用哪种特效,取值为1-23:
  0 矩形缩小
  1 矩形扩大
  2 圆形缩小
  3 圆形扩大
  4 下到上刷新
  5 上到下刷新
  6 左到右刷新
  7 右到左刷新
  8 竖百叶窗
  9 横百叶窗
  10 错位横百叶窗
  11 错位竖百叶窗
  12 点扩散
  13 左右到中间刷新
  14 中间到左右刷新
  15 中间到上下
  16 上下到中间
  17 右下到左上
  18 右上到左下
  19 左上到右下
  20 左下到右上
  21 横条
  22 竖条
  23 以上22种随机选择一种

39.在规定时间内跳转
<META http-equiv=V="REFRESH" content="5;URL=http://www.51js.com">

40.网页是否被检索
<meta name="ROBOTS" content="属性值">
  其中属性值有以下一些:
  属性值为"all": 文件将被检索,且页上链接可被查询;
  属性值为"none": 文件不被检索,而且不查询页上的链接;
  属性值为"index": 文件将被检索;
  属性值为"follow": 查询页上的链接;
  属性值为"noindex": 文件不检索,但可被查询链接;
  属性值为"nofollow": 文件不被检索,但可查询页上的链接。

41.变换网页的鼠标光标
<BODY style="CURSOR: url(http://203.73.125.205/~liangmi2/farmfrog01.cur`)">

42.怎样实现在任务栏显示小图标的效果? (要使用绝对地址)
有些站点,访问时会在地址栏地址前显出小图标,添加到收藏夹后也在收藏栏中显示图标,
这样很好的与其它站点有了区别。
要达到这个效果,先需做出这个图标文件,图像为16*16像素,不要超过16色。文件格式为ico,然后上传至你的网站。
然后,在需要的页面中,加上以下html语句到文件的<head>和</head>之间(假设以上ico文件的地址http://happyisland.126.com/icon.ico)。
<link REL="SHORTCUT ICON"href="http:///happyisland.126.com/icon.ico";>
如果访问者的浏览器是IE5.0,就不需加任何代码,只要将图标文件上传到网站的根目录下即可。
1,META标签里的代码是什么意思?
<META>是放于<HEAD>与</HEAD>之间的标记.以下是我总结它在网页中最常见的几种。
<meta name="Keywords" content="图片, 新闻, 音乐, 软件">
该网页的关键字,作用于搜索引擎的登录,事实上它在现在的网站中并没什么用。
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
设定这是 HTML 文件及其编码语系,简体中文网页使用charset=gb2312,繁体中文使用charset=big5,或者不设编码也可,纯英文网页建议使用 iso-8859-1。
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
这只表示该网页由什么编辑器写的。
<meta http-equiv="refresh" content="10; url=http://www.hkiwc.com">
这行较为实用,能于预定秒数内自动转到指定网址。原代码中 10 表示 10秒。

2,怎么改变滚动条的颜色,只有ie5.5版本以上才能支持。
这是使用CSS语言,在次说明一下,它和我的浏览器版本有一定的关系。
scrollbar-arrow-color:上下按钮上三角箭头的颜色。
scrollbar-base-color:滚动条的基本颜色。
scrollbar-dark-shadow-color:立体滚动条强阴影的颜色
scrollbar-face-color:立体滚动条凸出部分的颜色
scrollbar-highlight-color:滚动条空白部分的颜色
scrollbar-shadow-color立体滚动条阴影的颜色。
scrollbar-track-color:#99CC33;
scrollbar-3dlight-color:#A8CBF1;
代码如下:
<style>
<!--
BODY {
scrollbar-face-color:#99CC33;//(立体滚动条凸出部分的颜色)
scrollbar-highlight-color:#A8CBF1;//(滚动条空白部分的颜色)
scrollbar-shadow-color:#A8CBF1;//(立体滚动条阴影的颜色)
scrollbar-arrow-color:#FF9966;//(上下按钮上三角箭头的颜色)
scrollbar-base-color:#A8CBF1; //(滚动条的基本颜色)
scrollbar-darkshadow-color:#A8CBF1; //(立体滚动条强阴影的颜色)
scrollbar-track-color:#99CC33;
scrollbar-3dlight-color:#A8CBF1;
}
-->
</style>
在这我补充几点:
1.让浏览器窗口永远都不出现滚动条。
<body style="overflow-x:hidden;overflow-y:hidden">或<body style="overflow:hidden"> 或<body scroll=no>
2,没有水平滚动条
<body style="overflow-x:hidden">
3,没有垂直滚动条
<body style="overflow-y:hidden">

3,如何给图片抖动怎做的.
<SCRIPT language=javascript1.2>
<!--
var rector=2
var stopit=0
var a=1
var count=0
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1||count==100)
return
count++
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
count=0
which.style.left=0
which.style.top=0
}
//-->
</SCRIPT>
<style>.shakeimage {POSITION: relative}
</style>
<img src="图片的路径" onmouseout=stoprattle(this) onmouseover=init(this);rattleimage() class=shakeimage>

4,在DW如何给水平线加颜色。
在DW中没有此项设置,你只能在HTML中加入代码:<hr color=red noshade>按F12的预览在能看到。由于在NC中不支持<hr>的COLOR属性,所以在DW中没有此项设置。
   
5,如何在网页中实现flash的全屏播放?
只要在调用swf文件的HTML中将WIDTH和HEIGHT的参数设为100%即可,当然也可以在Flash导出HTML文件的设置中进行设置,方法是:打开File菜单;选Publish Settings弹出导出设置对话框;在HTML标签下的Dimensions选项,下拉后选中Percent(百分比),并在WIDTH 和HEIGHT框中填100.就行了。

6,为什么我在DW中插入的Flash动画缺看不找!
如果你没有正确地安装Dreamweaver和Flash,那么在你预览的时候,Dreamweaver会提示你缺少播放的插件,请你按装InstallAXFlash.exe 并从新启动计算机。现在IE6已经捆绑这个程序。

7,在Flash中,如果屏蔽鼠标右键?FS命令都是什么意思?
fscommand ("fullscreen", "true/false";(全屏设置,TRUE开,FALSE关)
fscommand ("showmenu", "true/false";(右键菜单设置,TRUE显示,FALSE不显示)
fscommand ("allowscale", "true/false";(缩放设置,TRUE自由缩放,FALSE调整画面不影响影片本身的尺寸)
fscommand ("trapallkeys", "true/false";(快捷键设置,TRUE快捷键开,FALSE快捷键关)
fscommand ("exec";(EXE程序调用)
fscommand ("quit";(退出关闭窗口)

8,Flash中什么是隐形按钮。
利用button中的hit帧来制作只有感应区域而完全透明的按钮。

9,如何给Flash动画做链接。
Dreamweaver是不能给Flash制作链接的,只能在Flash中用geturl()加链接,然后再插入Dreamweaver中。

10,DW中的层的技巧。
层是可以嵌套的,我个人给大家一个技巧,在层面板中按住CTRL再拖放层到你想去成为其子层的地方就行了,我认为这是最简单直观的方法了。

11,如何改变鼠标的形状?
在Dreamweaver4中CSS样式面板:
按CTR +SHIFT+E--出现样式表对话框,点击NEW,出现编辑对话框,在左边最后一项extensions-cursor 选择你要改的指针形式就可以了,然后把你要想改变的地方运用样式表,如果整页都有在<body bgcolor="#003063" text="#ffffff" id= all>中加入就行了。
<span style="cursor:X`>样例</span>
这里选择(文本)作为对象,还可以自己改为其他的,如link等。
x 可以等于=hand(手形)、crosshair(十字)、text(文本光标)、wait(顾名思义啦)、default(默认效果)、help(问号)、e-size(向右箭头)、ne-resize(向右上的箭头)、nw-resize(向左上的箭头)、w-resize(向左的箭头)、sw- resize(左下箭头)、s-resize(向下箭头)、se-resize(向右下箭头)、auto(系统自动给出效果)。

12,用CSS做邮票,看看吧!
<input type=button value=我象不象邮票? style="height:80px;border:2px dashed #cccccc">

13,经常上网的朋友可能会到过这样一些网站,一进入首页立刻会弹出一个窗口,怎么做呢!
这javascript代码即可实现,摘录蓝色论坛。
【1、最基本的弹出窗口代码】
其实代码非常简单:
<SCRIPT LANGUAGE="javascript">
<!--
window.open (`page.html`)
-->
</SCRIPT>
因为着是一段javascripts代码,所以它们应该放在<SCRIPT LANGUAGE="javascript">标签和< /script>之间。<!-- 和 -->是对一些版本低的浏览器起作用,在这些老浏览器中不会将标签中的代码作为文本显示出来。要养成这个好习惯啊。
window.open (`page.html`) 用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。用单引号和双引号都可以,只是不要混用。
这一段代码可以加入HTML的任意位置,<head>和</head>之间可以,<body bgcolor= "#003063" text="#ffffff" id=all>间</body>也可以,越前越早执行,尤其是页面代码长,又想使页面早点弹出就尽量往前放。
【2、经过设置后的弹出窗口】
下面再说一说弹出窗口的设置。只要再往上面的代码中加一点东西就可以了。
我们来定制这个弹出的窗口的外观,尺寸大小,弹出的位置以适应该页面的具体情况。
<SCRIPT LANGUAGE="javascript">
<!--
window.open (`page.html`, `newwindow`, `height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no`)
//写成一行
-->
</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="javascript"> js脚本开始;
window.open 弹出新窗口的命令;
`page.html` 弹出窗口的文件名;
`newwindow` 弹出窗口的名字(不是文件名),非必须,可用空``代替;
height=100 窗口高度;
width=400 窗口宽度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏。
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</SCRIPT> js脚本结束
【3、用函数控制弹出窗口】
下面是一个完整的代码。
<html>
<head>
<script LANGUAGE="javascript">
<!--
function openwin() { window.open ("page.html", "newwindow", "height=100, width=400, toolbar=
no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"
//写成一行
}
//-->
</script>
</head>
<body onload="openwin()">
…任意的页面内容…
</body>
</html>
这里定义了一个函数openwin(),函数内容就是打开一个窗口。在调用它之前没有任何用途。
怎么调用呢?
方法一:<body onload="openwin()"> 浏览器读页面时弹出窗口;
方法二:<body onunload="openwin()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:
<a href="#" onclick="openwin()">打开一个窗口</a>
注意:使用的“#”是虚连接。
方法四:用一个按钮调用:
<input type="button" onclick="openwin()" value="打开窗口">

14,没有用表格写的,让大家随便看看,没什么。
<html>
<head>
<title>江南荷花扇面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.font1 { font-size: 12px; color: #999999; text-decoration: none}
a { font-size: 12px; color: #999999; text-decoration: none}
a:hover { font-size: 12px; color: #000000; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="font1" style="writing-mode=tb-rl;height:200px" width=300>
<p>盛夏      尚 涛 
<p><a href="index.htm">一夜露痕黄粉香 袁运甫 </a>
<p>瑶池昨夜新凉  王金岭
<p>一朵白莲随意开 吴冠南
<p>新雨迎秋欲满塘 齐辛民
<p>十里荷香    齐辛民
<p>濯清莲而不妖  卢世曙
</div>
</body>
</html>

15,IE6已支持自定义cursor!
语法格式 cursor:url(图标) //cur或是ani文件.
cur就是WINDOWS中的光标(cursor)文件,光标文件与图标(ICON)文件除了文件头有一个位置的值不同外,实际是一样的。
ani是WINDOWS中的动画光标(图标)文件。
<style type="text/css">
<!--
.unnamed1 { cursor:url(arrow2c.cur)}
-->
</style>

16,用marquee做的滚动字幕.这也我刚看到论坛的朋友在问。
语法:
align=# | top | middle| bottom //对齐方式)
BEHAVIOR=ALTERNATE | SCROLL | SLIDE //移动的方式
BGCOLOR=color//底色区域颜色
DIRECTION=DOWN | LEFT | RIGHT | UP //移动的方向
Loop=n //循环次数(默认是循环不止)
Scrolldelay=milliseconds//延时
height=# width=# //区域面积
hspace=# vspace=# //空白区域
scrollamount=# //移动的速度
<marquee align=top behavior=ALTERNATE BGCOLOR=#000000 height=60 width=433 scrollamount=5></marquee>

17,在FLASH5中也存在一些字体,打散后变成一团的事是为什么?有解决的办法吗。
这是大家很常见的问题!可能是对字库支持的不好!我个是做成透明的gif图片格式,然后倒入。

18,flash的网页里“加入收藏夹”功能怎么实现?
在as中加getUrl("java script:window.external.addFavorite(http://skydesigner.51.net`,`我的工作室`)"

19,在Flash中,文本的动态属性和输入属性的区别。
input text在运行时可被用户或程序改变其值。
ynamic text仅允许被程序修改。

20,怎样在IE中调用Dreamweaver进行编辑.
相信很多在使用WinME或Window2000的朋友,会遇见是个问题。很简单,把我们笔记本程序打开,保存为一个 *.reg 文件。双击它将信息添加到注册表即可。
REGEDIT4
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver]
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver/shell]
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver/shell/edit]
[HKEY_CLASSES_ROOT/.htm/OpenWithList/Dreamweaver/shell/edit/command]
@="/"c://Program Files//Macromedia//Dreamweaver 4//dreamweaver.exe/" /"%1/""

21,设置表格虚线。
方法一:作一个1X2的图。半黑半白,再利用表格作成线。
方法二:在css里面设,要IE5。5才支持这种效果。
style="BORDER-LEFT: #000000 1PX DASHED; BORDER-RIGHT: #000000 1PX DASHED; BORDER-TOP: #000000 1PX DASHED; BORDER-BOTTOM: #000000 1PX DASHED"

22,看看在网页中调用HHCtrl控件效果。
代码如下:
<object id="HHC" type="application/x -oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"></object> <script>HHC.TextPopup("哈哈,大家好,我是闪梦!","",50,5,128255,346751);< /script>

22,如何让一张图片有浅到深的渐变。
<SCRIPT language=javascript1.2>
<!--
function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=40
}
function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
</script>
<img onmouseout=low(this) onmouseover=high(this) style="FILTER: alpha(opacity=40)"src="logo.gif" >

23,双击鼠标左键来滚动背景,单击停止。
<SCRIPT language=javascript>
var currentpos,timer;
function initialize()
{
timer=setInterval("scrollwindow()",16);
}
function sc(){
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</SCRIPT>

24,如何在同一页面设置不同文字链接效果的样式.
代码如下:
<HTML><HEAD><TITLE>如何在同一页面设置不同文字链接效果的样式</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
a:hover { font-size: 9pt; color: #FF0000; text-decoration: underline}
a:link { font-size: 9pt; color: #006699; text-decoration: underline}
a:visited { font-size: 9pt; color: #006699; text-decoration: underline}
a:active { font-size: 9pt; color: #FF0000; text-decoration: none}
a.r1:hover { font-size: 9pt; color: #FF0000; text-decoration: underline overline}
a.r1:link { font-size: 9pt; color: #000000; text-decoration: underline overline}
a.r1:visited { font-size: 9pt; color: #99CC00; text-decoration: underline overline}
a.r1:active { font-size: 9pt; color: #000000; text-decoration: underline overline}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<a href="#">下划线链接 </a>
<p></p>
<a href="#" class="r1">双下划线链接</a>
</BODY>
</HTML>
补充说明:
a:hover 表示鼠标划过时的样式.
a:link 表示链接的样式.
a:active 表示当前活动连接的样式.
a:visited 表示已经访问过的连接的样式.

25, 用CSS给文字加入阴影效果和文字描边效果。
.glow{FONT-SIZE: 9pt; FILTER: Glow(Color=#000000, Strength=1)}
//文字描边效果
.shadow  {FONT-SIZE: 9pt; FILTER: DropShadow(OffX=1, OffY=1, DropShadow(OffX=1, OffY =1, color:#111111); COLOR: #ffffff; FONT-FAMILY: "宋体"}
//加入阴影效果
补充说明:
  这两种滤镜要想实现效果,必须加在如:<td class=glow或shadow ><div>xxxxxxxxx</div></td>上
,并且要留有足够的空间能够显示阴影或描边,否则会出现半截的阴影或描边现象。

26,如何给做带颜色的下拉菜单。
<select style="FONT-SIZE: 10px; COLOR: #ffffff; FONT-FAMILY: Verdana;BACKGROUND-COLOR: #ff6600;" size=1 >
<option selected>:: Dreamweaver4 ::</option>
<option>::Flash5::</option>
<option>::Firewoks4::</option>
</select>

27,关于DW4的表格中的亮边框和暗边框问题。
在DW4的表格面板中并没有亮边框和暗边框的属性设置,因为NC不支持,只有你在代码中添加了。
bordercolorlight="#999999" bordercolordark="#000000"
  你也可以用Css定义一个class。例如:
<style>
.bordercolor { bordercolorlight: #999999; bordercolordark: #000000 }
</style>
  然后在要加效果的表格里加上<table class="bordercolor">

28,自动显示主页最后更新日期.
<script>
document.write("最后更新日期:"+document.lastModified+""
</script>

29,如何让滚动条出现在左边?
我想居然在论坛中有人发表了这段代码,很有意思,它的确照顾一些左撇子,呵呵!
<html dir="rtl">
<body bgcolor="#000000" text="#FFFFFF">
<table height=18 width=212 align=center bgcolor=#FFFFFF dir="ltr" cellspacing="1"  cellpadding="0">
<tr>
<td bgcolor="#FF0000" >是不是你的滚动条在左边啊</td>
</tr>
</table>
</body>
</html>

30,如何加入网址前面的小图标?
  首先,您必须了解所谓的图标(Icon)是一种特殊的图形文件格式,它是以 .ico 作为扩展名。你可用在网上找一个制作图标软件,它具有特有的规格:图标的大小为 16 * 16(以像素为单位);颜色不得超过 16 色。 在该网页文件的 HEAD 部分加入下面的内容:< LINK REL="SHORTCUT ICON" HREF=" http://skydesigner.51.net/图标文件名">,并放在该网页的根目录下。

31,在800*600显示器中,如何不让网页水平出现滚动条!
设至<body leftmargin="0" topmargin="0">,网页中的表格宽度为778。

32,关于<!DOTYPE>的说明解释。
在网页中,经常会看到〈!DOCTYPE HTML PUBLIC`-//W3C//DTD HTML 4.01//EN`>,是声明HTML文件的版本信息。

33, 用图片来关闭窗体.
<A href="java script:window.close()"><IMG height=20 width=20 alt="关闭窗口" src="close.gif" border=0></A>
补充说明:如何使用了ACTIVEX!,不再警告窗口?
<html>
<head>
<object id=closes type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close"></object>
</head>
<body bgcolor="#003063" text="#ffffff" id=all> <a href="#" onclick="closes.Click();">关闭窗口无提示</a>
</body>
</html>

34,禁止鼠标右键查看网页源代码。
<SCRIPT language=javascript>
function click()
{if (event.button==2) {alert(`你好,欢迎光临!`) }}
document.onmousedown=click
</SCRIPT>
补充说明:
鼠标完全被封锁,可以屏蔽鼠标右键和网页文字。
< body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">

35,通过按钮来查看网页源代码。
<input type="BUTTON" value="查看源代码" onClick= `window.location = "view-source:" + window.location.href` name="BUTTON">

36,怎么用文字联结实现按钮的SUBMIT功能?
<a href="#" onclick="formname.submit()">OK</a>
这段文字要放在form里。formname是这里要写在form中的name,<form name=form111>那么就应该是form111.submit()

37,如何做一个空链接?
加#

38,利用<IFRAME>来给网页中插入网页。
  经常我看到很多网页中又有一个网页,还以为是用了框架,其实不然,是用了<IFRAME>,它只适用于IE,NS可是不支持< IFRAME>的,但围着的字句只有在浏览器不支援 iframe 标记时才会显示,如<noframes>一样,可以放些提醒字句之类的话。
你注意啊!下面请和我学习它的用法。
分析代码:<iframe src="iframe.html" name ="test" align="MIDDLE" width="300" height="100" marginwidth="1" marginheight="1" frameborder="1" scrolling="Yes"> </iframe>
  src="iframe.html"
  用来显示<IFRAME>中的网页来源,必要加上相对或绝对路径。
  name="test"
  这是连结标记的 target 参数所需要的。
  align="MIDDLE"
  可选值为 left, right, top, middle, bottom,作用不大 。
  width="300" height="100"
  框窗的宽及长,以 pixels 为单位。
  marginwidth="1" marginheight="1"
  该插入的文件与框边所保留的空间。
  frameborder="1"
  使用 1 表示显示边框, 0 则不显示。(可以是 yes 或 no)
  scrolling="Yes"
  使用 Yes 表示容许卷动(内定), No 则不容许卷动。

39,请问<tbody>的用法?
tbody用法据说是加强对表格的控制能力的.例如:
 <table><tbody>……..</tbody></table>
  tbody代码如果不是你用手写的话,只有在你用IE5打开一个网页的时候, 把它另存为
一下,你的另存为的文件在表格中就会生成tbody代码。(即便你的表格根本就没有
tbody代码,IE5另存为的时候也会给你生成)。

40,Alt和Title都是提示性语言标签,请注意它们之间的区别。
  在我们浏览网页时,当鼠标停留在图片对象或文字链接上时,在鼠标的右下角有时会出现一个提示信息框。对目标进行一定的注释说明。在一些场合,它的作用是很重要的。
alt 用来给图片来提示的。Title用来给链接文字或普通文字提示的。
用法如下:
   <p Title="给链接文字提示">文字</p>
   <a href="#" Title="给链接文字提示">文字</a>
   <img src="图片.gif" alt="给图片提示">
补充知识:<TITLE><ALT>里面如何多行换行?在源代码里Enter回车。
<a href="#" Title="个人简历
姓名:张培
网名:我是闪梦
性别:男的,不是女的。
爱好:网页制作,软件开发">个人简历</a>
例如:个人简历

41, 用javascript代码来实现闪烁按钮。
<body>
<form method="POST" action="--WEBBOT-SELF--">
<input type="button" name=SUB value="闪烁" id=flashit style="BORDER: 1px solid ;BACKGROUND-COLOR: #FFFFFF">
</form>
<script>
if (document.all&&document.all.flashit)
{
var flashelement=document.all.flashit
if (flashelement.length==null)
flashelement[0]=document.all.flashit
function changecolor(which)
{
if (flashelement[which].style.color==`#800000`)
flashelement[which].style.color="#0063A4"
else
flashelement[which].style.color="#800000"
}
if (flashelement.length==null)
setInterval("changecolor(0)",1000)
else
for (i=0;i<flashelement.length;i++)
{
var tempvariable=`setInterval("changecolor(`+i+`)",`+`1000)`
eval(tempvariable)
}
}
</script>
</body>

42,CSS给图片定义颜色边框。
img { border: 1px solid red}

43,在DW中如何使插入的FLASH透明。
方法一:选中swf,打开原代码窗口,在</object>前输入:<param name="wmode" value="transparent">
方法二:在Flash中的Flie→Publist Settings→HTML→Window Mode选择transparent

44,在DW编辑文本中,如何输入一个空格呢?
输入空格的问题,在DW似乎已成了一个老生常谈的问题。通过将输入法调整到全角模式就可以避免了。本以人工智能ABC为例.按Shift+Space切换到全角状态。

45,为何我的DW中图形显示不正常。
第一种:可能是因为你定义并正在使用一个site,而你的HTML文件或者图片不在这个site包含的区域之内,因此dreamweaver使用file协议来
描述图象的绝对路径,可惜IE不支持src中使用file协议,所以图象就显示不出来了。
第二种:可能是放图片的文件夹或图片名为中文,也显示不到网页中去。

46,如何在本地机器上测试flash影片的loading?
我想这可能是很多人在问的题了,其实很简单,在Test时,选选View->Show Streaming就可以看到了。

47,在网页中做出一根竖的线有几种办法.
第一种方法:用一个像素图的办法!
如果你用Dreamwever的Edit→Preferences…→Layout View中的Spacer Image给你创建了一个缺省名为:spacer.gif的一个像素图文件 。
代码中:
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000" height="200" ><img src="spacer.gif" width="1" height="1"></td>
</tr>
</table>
第二种方法:用表格填颜色的办法!把<td> </td>中的 删掉 .
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FF0000" height="200" width="1"></td>
</tr>
</table>
第三种方法:用水平条。
<hr color="red" width="1" size="100%">

48, 关于鼠标拖动,改变层大小。──看看微软的做法.
<script>
document.execCommand("2D-position",false,true);
</script>
<DIV contentEditable=true>
<DIV style="WIDTH: 300px; POSITION: absolute; HEIGHT: 100px; BACKGROUND-COLOR: red">移动层</DIV>
</DIV>


让弹出窗口总是在最上面: <body onblur="this.focus();">
不要滚动条? 让竖条没有: <body style='overflow:scroll;overflow-y:hidden'> </body>
让横条没有: <body style='overflow:scroll;overflow-x:hidden'> </body>
两个都去掉?更简单了 <body scroll="no"> </body>
怎样去掉图片链接点击后,图片周围的虚线? <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>
电子邮件处理提交表单 <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain"> <input type=submit> </form>
在打开的子窗口刷新父窗口的代码里如何写? window.opener.location.reload()
如何设定打开页面的大小 <body onload="top.resizeTo(300,200);">
在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动 <html><head> <STYLE> body {background-image:url(logo.gif); background-repeat:no-repeat; background-position:center } </STYLE> </head> <body bgproperties="fixed" > </body> </html>

各种样式的光标 auto :标准光标
default :标准箭头
hand :手形光标
wait :等待光标
text :I形光标
vertical-text :水平I形光标
no-drop :不可拖动光标
not-allowed :无效光标
help :?帮助光标
all-scroll :三角方向标
move :移动标
crosshair :十字标 e-resize n-resize nw-resize w-resize s-resize se-resize sw-resize

本机ip<%=request.servervariables("remote_addr")%>
服务器名<%=Request.ServerVariables("SERVER_NAME")%>
服务器IP<%=Request.ServerVariables("LOCAL_ADDR")%>
服务器端口<%=Request.ServerVariables("SERVER_PORT")%>
服务器时间<%=now%> IIS
版本<%=Request.ServerVariables"SERVER_SOFTWARE")%>
脚本超时时间<%=Server.ScriptTimeout%>
本文件路径<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%>
服务器CPU数量<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%>
服务器解译引擎<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %>
服务器操作系统<%=Request.ServerVariables("OS")%>

文本竖排方式
<style type="text/css">
<!--
.shupai {Writing-mode:tb-rl}
-->
</style>
超链接去虚线边框
在链接中加上onfocus="this.blur()"

网页搜索关键字 头里插入
<META NAME="keywords" CONTENT="xxxx,xxxx,xxx,xxxxx,xxxx,">

收藏夹图标
<link rel = "Shortcut Icon" href="favicon.ico">

我的电脑
file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
网上邻居
file:///::%7B208D2C60-3AEA-1069-A2D7-08002B30309D%7D
我的文档
file:///::%7B450D8FBA-AD25-11D0-98A8-0800361B1103%7D
控制面板
file:///::{20D04FE0-3AEA-1069-A2D8-08002B30309D}/::{21EC2020-3AEA-1069-A2DD-08002B30309D}
回收站
file:///::%7B645FF040-5081-101B-9F08-00AA002F954E%7D

鼠标控制图片隐现效果
把如下代码加入<body>区域中:
<SCRIPT language="javascript">
<!--
function makevisible(cur,which){
if (which==0)
cur.filters.alpha.opacity=100
else
cur.filters.alpha.opacity=20
}
//-->
</SCRIPT>
  2、把如下代码加入<body>区域中:
<img src="2.gif" style="filter:alpha(opacity=20)"
onMouseOver="makevisible(this,0)"
onMouseOut="makevisible(this,1)">

禁止图片下载
<A HREF="javascript:void(0)" onMouseover="alert('对不起,此图片不能下载!')">
<IMG SRC="2.gif" Align="center" Border="0" width="99" height="50"></A>

页嵌页
<iframe width=291 height=247 src="main.files/news.htm" frameBorder=0></iframe>

隐藏滚动条
<body style="overflow-x:hidden;overflow-y:hidden"

CSS文字阴影(定义在<TD>中)
.abc{
FILTER: dropshadow(color=#666666, offx=1, offy=1, positive=1); FONT-FAMILY: "宋体"; FONT-SIZE: 9pt;COLOR: #ffffff;
}

列表/菜单
onchange="location=this.options[this.selectedIndex].value"

<iframe id="frm" src="k-xinwen.html" scrolling="no" width="314" height="179"></iframe>
<img src="xiangshang.jpg" onMouseOver="sf=setInterval('frm.scrollBy(0,-2)',1)" onMouseOut="clearInterval(sf)" width="31" height="31">
<img src="xiangxia.jpg" onMouseOver="sf=setInterval('frm.scrollBy(0,2)',1)" onMouseOut="clearInterval(sf)" width="31" height="31" >

 reurl=server.htmlencode(request.ServerVariables("HTTP_REFERER"))

服务器上如何定义连接
MM_www_STRING ="driver={Microsoft access Driver (*.mdb)};dbq=" & server.mappath("../data/www.mdb")

链接到
response.redirect"login.asp"
location.href="xx.asp"

onClick="window.location='login.asp'"
onClick="window.open('')"

取得IP
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")

sql="update feedbak set hit=hit+1 where id="&request("id")
conn.execute(sql)

截取字符是否加...
function formatStr(str,len)
if(len(str)>len)
str = left(str,len) + "..."
end if
formatStr = str
end function

接收表单
If Ucase(Request.ServerVariables("REQUEST_METHOD")) = "POST" then
end if


图片宽度
<script language="javascript">
<!--
var flag=false;
function DrawImage(ckp){
var image=new Image();
image.src=ckp.src;
if(image.width>0 && image.height>0)
{flag=true;
if(image.width>120){
ckp.width=120;
}else{
ckp.width=image.width;
}
ckp.alt=image.width+"×"+image.height;
}
}
//-->
</script>
I'll be Back 22:18:06
<img src="<%=formPath%>/<%=rs("photoname")%>" border="0" onload="javascript:DrawImage(this);">

跳转
<meta http-equiv=refresh content='0; url=/distributor/distributor.aspx'>

 溢出栏的设制
visible:超出的部分照样显示;
hidden:超出的部分隐藏;
scrool:不管有否超出,都显示滚动条;
auto:有超出时才出现滚动条;

onMouseOver:鼠标移到目标上;
onMouseUp:按下鼠标再放开左键时;
onMouseOut:鼠标移开时;
onMouseDown:按下鼠标时(不需要放开左键);
onClink:点击时;
onDblClick:双击时;
onLoad:载入网页时;
onUnload:离开页面时;
onResize:当浏览者改变浏览窗口的大小时;
onScroll:当浏览者拖动滚动条的时。

CSS样式
a:link:表示已经链接;
a:hover:表示鼠标移上链接时;
a:active:表示链接激活时;
a:visited:表示己点击过的链接。

跳出对话框链接
javascript:alert('lajflsjpjwg')
后退:javascript:history.back(1)
关闭窗口:javascript:window.close();
窗口还原
function restore(){
window.moveTo(8,8);
window.resizeTo(screen.width-24,screen.availHeight-24);
}

head区是指首页HTML代码的<head>和</head>之间的内容。
必须加入的标签

1.公司版权注释
<!--- The site is designed by Maketown,Inc 06/2000 --->

2.网页显示字符集
简体中文:<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
繁体中文:<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=BIG5">
英 语:<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

3.网页制作者信息
<META name="author" content="webmaster@maketown.com">

4.网站简介
<META NAME="DESCRIPTION" CONTENT="xxxxxxxxxxxxxxxxxxxxxxxxxx">

5.搜索关键字
<META NAME="keywords" CONTENT="xxxx,xxxx,xxx,xxxxx,xxxx,">

6.网页的css规范
<LINK href="style/style.css" rel="stylesheet" type="text/css">
(参见目录及命名规范)

7.网页标题
<title>xxxxxxxxxxxxxxxxxx</title>

.可以选择加入的标签

1.设定网页的到期时间。一旦网页过期,必须到服务器上重新调阅。
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">

2.禁止浏览器从本地机的缓存中调阅页面内容。
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

3.用来防止别人在框架里调用你的页面。
<META HTTP-EQUIV="Window-target" CONTENT="_top">

4.自动跳转。
<META HTTP-EQUIV="Refresh" CONTENT="5;URL=http://www.yahoo.com">
5指时间停留5秒。

5.网页搜索机器人向导.用来告诉搜索机器人哪些页面需要索引,哪些页面不需要索引。
<META NAME="robots" CONTENT="none">
CONTENT的参数有all,none,index,noindex,follow,nofollow。默认是all。

6.收藏夹图标
<link rel = "Shortcut Icon" href="favicon.ico">

所有的javascript的调用尽量采取外部调用.
<SCRIPT LANGUAGE="javascript" SRC="script/xxxxx.js"></SCRIPT>

附<body>标签:
<body>标签不属于head区,这里强调一下,为了保证浏览器的兼容性,必须设置页面背景<body bgcolor="#FFFFFF">

flash透明
在flash的源代码中加上:<param name="wmode" value="transparent">

表格透明
style="FILTER: alpha(opacity=72)"

网址前添加icon的方法
1、上http://www.favicon.com上用他的icon editor online制作一个图标。他会将做好的图标通过email即时发送给你。
2、把这个命名为favicon.ico的图标放置在index.html同一个文件夹中。就可以了。
作一个图标文件,大小为16*16像素。文件扩展名为ico,然后上传到相应目录中。在HTML源文件“<head></head>”之间添加如下代码:
<Link Rel="SHORTCUT ICON" href="http://图片的地址(注意与刚才的目录对应)">
其中的“SHORTCUT ICON”即为该图标的名称。当然如果用户使用IE5或以上版本浏览时,就更简单了,只需将图片上传到网站根目录下,自动识别

可以在收藏夹中显示出你的图标<link rel="Bookmark" href="favicon.ico">

状态栏连接说明
<A HREF="链接到某处" onmouseOver="window.status='连接说明';return true;" onMouseOut="window.status=' ';">某某链接</a>

链接说明
<a href=“”Title=链接说明>

禁止鼠标右键
在<body>标签中加入 <body oncontextmenu="return false">

DW里输入空格
插入N个&nbsp;

水平线
<hr width="长度" size="高度" color="颜色代码" noshade> noshade为有无阴影

表单电子邮件提交
< form name="content" method="post" action="mailto:电子邮箱" >< /form>
文本域名为Subject 为邮件的标题

邮件链接定制
Mailto:地址 ? Subject=邮件的标题 &bc=抄送 &bcc=密件抄送

背景音乐
<bgsound src=地址 loop="-1">

禁止页面正文选取
<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()">

消除ie6自动出现的图像工具栏,设置 GALLERYIMG属性为false或no .
<IMG SRC="mypicture.jpg" HEIGHT="100px" WIDTH="100px" GALLERYIMG="no">

防止点击空链接时,页面往往重置到页首端。
代码“javascript:void(null)”代替原来的“#”标记

如何避免别人把你的网页放在框架中
<script language=“javascript”><!--if (self!=top){top.location=self.location;} -->< /script>

页面定时刷新
<meta http-equiv="Refresh" content="秒" >

页面定时转向新的地址
<meta http-equiv="refresh" content="秒;URL=url">

显示日期
<script language="javascript"><!--
today=new Date();
var week; var date;
if(today.getDay()==0) week="星期日"
if(today.getDay()==1) week="星期一"
if(today.getDay()==2) week="星期二"
if(today.getDay()==3) week="星期三"
if(today.getDay()==4) week="星期四"
if(today.getDay()==5) week="星期五"
if(today.getDay()==6) week="星期六"
date=(today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日"+" "
document.write("<span style='font-size: 9pt;'>"+date+week+"</span>");
// -->
</script>

设为首页
<A href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('url');">设为首页</A>

添加收藏
<A href="javascript:window.external.AddFavorite('url','title')">收藏本站</A>

文字滚动
插入边框为0的1行1列的表格,在表格中输入文字,选中文字,
按ctrl+t输入marquee direction="up", 回车即可让文字在表格区域内向上滚动。
(right、down可用于让文字或图象向右及向下滚动,修改html原代码还可以得到需要的滚动速度。


表单验正
<SCRIPT language=javascript>
function checkform(theform){
if(theform.name.value==""){
alert("姓名不能为空!");
theform.name.focus();
return false;
}
if(theform.tel.value==""){
alert("电话不能为空!");
theform.tel.focus();
return false;
}
}
</SCRIPT>

定义鼠标
body{cursor: url(cur.ani或cur);}

以图片方式插视频
<IMG height=240 loop=infinite dynsrc=http://amedia.efu.com.cn/EFUADD0001.rmvb width=320>

层在flash上面
< param name="wmode" value="opaque" >
延迟跳转
<meta http-equiv=refresh content='3; url=javascript:window.close();'>

导航条变色:
单元格<TR后面插入onmouseover="javascript:this.bgColor='#57AE00'" onmouseout="javascript:this.bgColor='#99CCFF'"

居中
<CENTER></CENTER>

空链接
javascript:;

标题表格
<fieldset>
<legend>表格的说明</legend>
</fieldset>

细线表格
style="BORDER-COLLAPSE: collapse;"

滚动条颜色代码
BODY{
SCROLLBAR-FACE-COLOR: #FFFFFF;
SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF;
SCROLLBAR-SHADOW-COLOR: #FFFFFF;
SCROLLBAR-3DLIGHT-COLOR: #FFCBC8;
SCROLLBAR-ARROW-COLOR: #FFFFFF;
SCROLLBAR-TRACK-COLOR: #FFFFFF;
SCROLLBAR-DARKSHADOW-COLOR: #FFCBC8;
SCROLLBAR-BASE-COLOR: #FFFFFF
}

连续的英文或者一堆感叹号!!!不会自动换行的问题
只要在CSS中定义了如下句子,可保网页不会再被撑开了

table{table-layout: fixed;}
td{word-break: break-all; word-wrap:break-word;}

注释一下:

1.第一条table{table-layout: fixed;},此样式可以让表格中有!!!(感叹号)之类的字符时自动换行。

2.td{word-break: break-all},一般用这句这OK了,但在有些特殊情况下还是会撑开,因此需要再加上后面一句{word-wrap:break-word;}就可以解决。此样式可以让表格中的一些连续的英文单词自动换行。

    * 14:09
    * 添加评论
    * 固定链接
    * 引用通告 (0)
    * 记录它
    * HTML

固定链接
单击隐藏此项的固定链接。
http://arrok.spaces.live.com/blog/cns!6FB6AD60AC46BCE3!115.entry
添加评论
单击隐藏此项的评论。
2006/3/9
js下的时间函数
Date (对象)
  Date 对象能够使你获得相对于国际标准时间(格林威治标准时间,现在被称为 UTC-Universal Coordinated Time)或者是 Flash 播放器正运行的操作系统的时间和日期。要使用Date对象的方法,你就必须先创建一个Date对象的实体(Instance)。

  Date 对象必须使用 Flash 5 或以后版本的播放器。

  Date 对象的方法并不是静态的,但是在使用时却可以应用于所指定的单独实体。

  Date 对象的方法简介:

  ·getDate      | 根据本地时间获取当前日期(本月的几号)
  ·getDay       | 根据本地时间获取今天是星期几(0-Sunday,1-Monday...)
  ·getFullYear    | 根据本地时间获取当前年份(四位数字)
  ·getHours      | 根据本地时间获取当前小时数(24小时制,0-23)
  ·getMilliseconds  | 根据本地时间获取当前毫秒数
  ·getMinutes     | 根据本地时间获取当前分钟数
  ·getMonth      | 根据本地时间获取当前月份(注意从0开始:0-Jan,1-Feb...)
  ·getSeconds     | 根据本地时间获取当前秒数
  ·getTime      | 获取UTC格式的从1970.1.1 0:00以来的毫秒数
  ·getTimezoneOffset | 获取当前时间和UTC格式的偏移值(以分钟为单位)
  ·getUTCDate     | 获取UTC格式的当前日期(本月的几号)
  ·getUTCDay     | 获取UTC格式的今天是星期几(0-Sunday,1-Monday...)
  ·getUTCFullYear   | 获取UTC格式的当前年份(四位数字)
  ·getUTCHours    | 获取UTC格式的当前小时数(24小时制,0-23)
  ·getUTCMilliseconds | 获取UTC格式的当前毫秒数
  ·getUTCMinutes   | 获取UTC格式的当前分钟数
  ·getUTCMonth    | 获取UTC格式的当前月份(注意从0开始:0-Jan,1-Feb...)
  ·getUTCSeconds   | 获取UTC格式的当前秒数
  ·getYear      | 根据本地时间获取当前缩写年份(当前年份减去1900)
  ·setDate      | 设置当前日期(本月的几号)
  ·setFullYear    | 设置当前年份(四位数字)
  ·setHours      | 设置当前小时数(24小时制,0-23)
  ·setMilliseconds  | 设置当前毫秒数
  ·setMinutes     | 设置当前分钟数
  ·setMonth      | 设置当前月份(注意从0开始:0-Jan,1-Feb...)
  ·setSeconds     | 设置当前秒数
  ·setTime      | 设置UTC格式的从1970.1.1 0:00以来的毫秒数
  ·setUTCDate     | 设置UTC格式的当前日期(本月的几号)
  ·setUTCFullYear   | 设置UTC格式的当前年份(四位数字)
  ·setUTCHours    | 设置UTC格式的当前小时数(24小时制,0-23)
  ·setUTCMilliseconds | 设置UTC格式的当前毫秒数
  ·setUTCMinutes   | 设置UTC格式的当前分钟数
  ·setUTCMonth    | 设置UTC格式的当前月份(注意从0开始:0-Jan,1-Feb...)
  ·setUTCSeconds   | 设置UTC格式的当前秒数
  ·setYear      | 设置当前缩写年份(当前年份减去1900)
  ·toString      | 将日期时间值转换成"日期/时间"形式的字符串值
  ·Date.UTC      | 返回指定的UTC格式日期时间的固定时间值

创建新的 Date 对象

  语法:
   new Date();
   new Date(year [, month [, date [, hour [, minute [, second [, millisecond ]]]]]] );
  参数:
   year     是一个 0 到 99 之间的整数,对应于 1900 到 1999 年,或者为四位数字指定确定的年份;
   month    是一个 0 (一月) 到 11 (十二月) 之间的整数,这个参数是可选的;
   date     是一个 1 到 31 之间的整数,这个参数是可选的;
   hour     是一个 0 (0:00am) 到 23 (11:00pm) 之间的整数,这个参数是可选的;
   minute    是一个 0 到 59 之间的整数,这个参数是可选的;
   second    是一个 0 到 59 之间的整数,这个参数是可选的;
   millisecond 是一个 0 到 999 之间的整数,这个参数是可选的;
  注释:
   对象。新建一个 Date 对象。
  播放器支持:
   Flash 5 或以后的版本。
  例子:
   下面是获得当前日期和时间的例子:
    now = new Date();
   下面创建一个关于国庆节的 Date 对象的例子:
    national_day = new Date (49, 10, 1);
   下面是新建一个 Date 对象后,利用 Date 对象的 getMonth、getDate、和 getFullYear方法获取时间,然后在动态文本框中输出的例子。
    myDate = new Date();
    dateTextField = (mydate.getMonth() + "/" + myDate.getDate() + "/" + mydate.getFullYear());


Date > Date.getDate
Date.getDate

  语法:myDate.getDate();
  参数:无
  注释:
   方法。根据本地时间获取当前日期(本月的几号),返回值是 1 到 31 之间的一个整数。
  播放器支持:Flash 5 或以后版本。

Date > Date.getDay
Date.getDay

  语法:myDate.getDay();
  参数:无
  注释:
   方法。根据本地时间获取今天是星期几(0-星期日,1-星期一...)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.getFullYear
Date.getFullYear

  语法:myDate.getFullYear();
  参数:无
  注释:
   方法。根据本地时间获取当前年份(四位数字,例如 2000)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。
  例子:
   下面的例子新建了一个 Date 对象,然后在输出窗口输出用 getFullYear 方法获得的年份:
   myDate = new Date();
   trace(myDate.getFullYear());

Date > Date.getHours
Date.getHours

  语法:myDate.getHours();
  参数:无
  注释:
   方法。根据本地时间获取当前小时数(24小时制,返回值为0-23之间的整数)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.getMilliseconds
Date.getMilliseconds

  语法:myDate.getMilliseconds();
  参数:无
  注释:
   方法。根据本地时间获取当前毫秒数(返回值是 0 到 999 之间的一个整数)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.getMinutes
Date.getMinutes

  语法:myDate.getMinutes();
  参数:无
  注释:
   方法。根据本地时间获取当前分钟数(返回值是 0 到 59 之间的一个整数)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.getMonth
Date.getMonth

  语法:myDate.getMonth();
  参数:无
  注释:
   方法。根据本地时间获取当前月份(注意从0开始:0-一月,1-二月...)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.getSeconds
Date.getSeconds

  语法:myDate.getSeconds();
  参数:无
  注释:
   方法。根据本地时间获取当前秒数(返回值是 0 到 59 之间的一个整数)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.getTime
Date.getTime

  语法:myDate.getTime();
  参数:无
  注释:
   方法。按UTC格式返回从1970年1月1日0:00am起到现在的毫秒数。使用这个方法可以描述不同时区里的同一瞬间的时间。
  播放器支持:Flash 5 或以后版本。

Date > Date.getTimezoneOffset
Date.getTimezoneOffset

  语法:mydate.getTimezoneOffset();
  参数:无
  注释:
   方法。获取当前时间和UTC格式的偏移值(以分钟为单位)。
  播放器支持:Flash 5 或以后版本。
  例子:
   下面的例子将返回北京时间与UTC时间之间的偏移值。
   new Date().getTimezoneOffset();
   结果如下:
   480 (8 小时 * 60 分钟/小时 = 480 分钟)

Date > Date.getUTCDate
Date.getUTCDate

  语法:myDate.getUTCDate();
  参数:无
  注释:
   方法。获取UTC格式的当前日期(本月的几号)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getUTCDay
Date.getUTCDay

  语法:myDate.getUTCDate();
  参数:无
  注释:
   方法。获取UTC格式的今天是星期几(0-星期日,1-星期一...)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getUTCFullYear
Date.getUTCFullYear

  语法:myDate.getUTCFullYear();
  参数:无
  注释:
   方法。获取UTC格式的当前年份(四位数字)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getUTCHours
Date.getUTCHours

  语法:myDate.getUTCHours();
  参数:无
  注释:
   方法。获取UTC格式的当前小时数(24小时制,返回值为0-23之间的一个整数)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getUTCMilliseconds
Date.getUTCMilliseconds

  语法:myDate.getUTCMilliseconds();
  参数:无
  注释:
   方法。获取UTC格式的当前毫秒数(返回值是 0 到 999 之间的一个整数)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getUTCMinutes
Date.getUTCMinutes

  语法:myDate.getUTCMinutes();
  参数:无
  注释:
   方法。获取UTC格式的当前分钟数(返回值是 0 到 59 之间的一个整数)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getUTCMonth
Date.getUTCMonth

  语法:myDate.getUTCMonth();
  参数:无
  注释:
   方法。获取UTC格式的当前月份(注意从0开始:0-一月,1-二月...)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getUTCSeconds
Date.getUTCSeconds

  语法:myDate.getUTCSeconds();
  参数:无
  注释:
   方法。获取UTC格式的当前秒数(返回值是 0 到 59 之间的一个整数)。
  播放器支持:Flash 5 或以后版本。

Date > Date.getYear
Date.getYear

  语法:myDate.getYear();
  参数:无
  注释:
   方法。根据本地时间获取当前缩写年份(当前年份减去1900)。本地时间由 Flash 播放器所运行的操作系统决定。例如 2000 年用100来表示。
  播放器支持:Flash 5 或以后版本。

Date > Date.setDate
Date.setDate

  语法:myDate.setDate(date);
  参数:date 为 1 到 31 之间的一个整数。
  注释:
   方法。根据本地时间设置当前日期(本月的几号)。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.setFullYear
Date.setFullYear

  语法:myDate.setFullYear(year [, month [, date]] );
  参数:
   year 指定的四位整数代表指定年份,二位数字并不代表年份,如99不表示1999,只表示公元99年
   month 是一个从 0 (一月) 到 11 (十二月) 之间的整数,这个参数是可选的。
   date 是一个从 1 到 31 之间的整数,这个参数是可选的。
  注释:
   方法。根据本地时间设定年份。如果设定了 month 和 date 参数,将同时设定月份和日期。本地时间由 Flash 播放器所运行的操作系统决定。设定之后 getUTCDay 和 getDay 方法所获得的值将出现相应的变化。
  播放器支持:Flash 5 或以后版本。

Date > Date.setHours
Date.setHours

  语法:myDate.setHours(hour);
  参数:hour 是一个从 0 (0:00am) 到 23 (11:00pm) 之间的整数。
  注释:
   方法。根据本地时间设置当前小时数。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.setMilliseconds
Date.setMilliseconds

  语法:myDate.setMilliseconds(millisecond);
  参数:millisecond 是一个从 0 到 999 之间的整数。
  注释:
   方法。根据本地时间设置当前毫秒数。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。


Date > Date.setMinutes
Date.setMinutes

  语法:myDate.setMinutes(minute);
  参数:minute 是一个从 0 到 59 之间的整数。
  注释:
   方法。根据本地时间设置当前分钟数。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.setMonth
Date.setMonth

  语法:myDate.setMonth(month [, date ]);
  参数:
   month 是一个从 0 (一月) 到 11 (十二月)之间的整数
   date 是一个从 1 到 31 之间的整数,这个参数是可选的。
  注释:
   方法。根据本地时间设置当前月份数,如果选用了 date 参数,将同时设定日期。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.setSeconds
Date.setSeconds

  语法:myDate.setSeconds(second);
  参数:second 是一个从 0 到 59 之间的整数。
  注释:
   方法。根据本地时间设置当前秒数。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.setTime
Date.setTime

  语法:myDate.setTime(millisecond);
  参数:millisecond 是一个从 0 到 999 之间的整数。
  注释:
   方法。用毫秒数来设定指定的日期。
  播放器支持:Flash 5 或以后版本。

Date > Date.setUTCDate
Date.setUTCDate

  语法:myDate.setUTCDate(date);
  参数:date 是一个从 1 到 31 之间的整数。
  注释:
   方法。按UTC格式设定日期,使用本方法将不会影响 Date 对象的其他字段的值,但是 getUTCDay 和 getDay 方法会返回日期更改过后相应的新值。
  播放器支持:Flash 5 或以后版本。

Date > Date.setUTCFullYear
Date.setUTCFullYear

  语法:myDate.setUTCFullYear(year [, month [, date]]);
  参数:
   year 代表年份的四位整数,如 2000
   month 一个从 0 (一月) 到 11 (十二月)之间的整数,可选参数。
   date 一个从 1 到 31 之间的整数,可选参数。
  注释:
   方法。按UTC格式设定年份,如果使用了可选参数,还同时设定月份和日期。设定过后 getUTCDay 和 getDay 方法会返回一个相应的新值。
  播放器支持:Flash 5 或以后版本。

Date > Date.setUTCHours
Date.setUTCHours

  语法:myDate.setUTCHours(hour [, minute [, second [, millisecond]]]));
  参数:
   hour 是一个从 0 (0:00am) 到 23 (11:00pm)之间的整数。
   minute 是一个从 0 到 59 之间的整数,可选参数。
   second 是一个从 0 到 59 之间的整数,可选参数。
   millisecond 是一个从 0 到 999 之间的整数,可选参数。
  注释:
   方法。设定UTC格式的小时数,如果是用可选参数,同时会设定分钟、秒和毫秒值。
  播放器支持:Flash 5 或以后版本。

Date > Date.setUTCMilliseconds
Date.setUTCMilliseconds

  语法:myDate.setUTCMilliseconds(millisecond);
  参数:millisecond 是一个从 0 到 999 之间的整数。
  注释:
   方法。设定UTC格式的毫秒数。
  播放器支持:Flash 5 或以后版本。

Date > Date.setUTCMinutes
Date.setUTCMinutes

  语法:myDate.setUTCMinutes(minute [, second [, millisecond]]));
  参数:
   minute 是一个从 0 到 59 之间的整数,可选参数。
   second 是一个从 0 到 59 之间的整数,可选参数。
   millisecond 是一个从 0 到 999 之间的整数,可选参数。
  注释:
   方法。设定UTC格式的分钟数,如果是用可选参数,同时会设定秒和毫秒值。
  播放器支持:Flash 5 或以后版本。

Date > Date.setUTCMonth
Date.setUTCMonth

  语法:myDate.setUTCMonth(month [, date]);
  参数:
   month 是一个从 0 (一月) 到 11 (十二月)之间的整数
   date 是一个从 1 到 31 之间的整数,这个参数是可选的。
  注释:
   方法。设定UTC格式的月份,同时可选设置日期。设定后 getUTCDay 和 getDay 方法会返回相应的新值。
  播放器支持:Flash 5 或以后版本。

Date > Date.setUTCSeconds
Date.setUTCSeconds

  语法:myDate.setUTCSeconds(second [, millisecond]));
  参数:
   second 是一个从 0 到 59 之间的整数,可选参数。
   millisecond 是一个从 0 到 999 之间的整数,可选参数。
  注释:
   方法。设定UTC格式的秒数,如果是用可选参数,同时会设定毫秒值。
  播放器支持:Flash 5 或以后版本。

Date > Date.setYear
Date.setYear

  语法:myDate.setYear(year);
  参数:year 是一个代表年份的四位整数,如 2000。
  注释:
   方法。根据本地时间设定年份。本地时间由 Flash 播放器所运行的操作系统决定。
  播放器支持:Flash 5 或以后版本。

Date > Date.toString
Date.toString

  语法:myDate.toString();
  参数:无
  注释:
   方法。将日期时间值转换成"日期/时间"形式的字符串值
  播放器支持:Flash 5 或以后版本。
  例子:
   下面的例子将国庆节的 national_day 对象输出成可读的字符串:
   var national_day = newDate(49, 9, 1, 10, 00);
   trace (national_day.toString());
   Output (for Pacific Standard Time):
  结果为:Sat Oct 1 10:00:00 GMT+0800 1949

Date > Date.UTC
Date.UTC

  语法:Date.UTC(year, month [, date [, hour [, minute [, second [, millisecond ]]]]]);
  参数:
   year 代表年份的四位整数,如 2000
   month 一个从 0 (一月) 到 11 (十二月)之间的整数。
   date 一个从 1 到 31 之间的整数,可选参数。
   hour 是一个从 0 (0:00am) 到 23 (11:00pm)之间的整数。
   minute 是一个从 0 到 59 之间的整数,可选参数。
   second 是一个从 0 到 59 之间的整数,可选参数。
   millisecond 是一个从 0 到 999 之间的整数,可选参数。
  注释:
   方法。返回指定时间距 1970 年 1 月 1 日 0:00am 的毫秒数。这是一个静态的方法,不需要特定的对象。它能够创建一个新的 UTC 格式的 Date 对象,而 new Date() 所创建的是本地时间的 Date 对象。
  播放器支持:Flash 5 或以后版本。