JavaScript程式碼收集

liwei66發表於2007-05-06
<script language="javascript" type="text/javascript"> </script>


 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 οnmοuseοver='this.stop()' οnmοuseοut='this.start()' height=60>
<!-- head_scrolltext -->
<tr>
<td>
共和國
</table>        <!-- end head_scrolltext -->
</marquee>使文字上下滾動

<input type="text" value="郭強" οnfοcus="if(value=='郭強') {value=''}" οnblur="if (value=='') {value='郭強'}">點選時文字消失,失去焦點時文字再出現


<base οnmοuseοver="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="提 交" οnmοuseοver="this.className='style2'" οnmοuseοut="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="提 交" οnmοuseοver="this.className='style4'" οnmοuseοut="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 οnchange='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 οnmοuseοver="this.bgColor='#FFFFFF';" οnmοuseοut="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 οnclick=haha()>
<INPUT TYPE="button" NAME="bb " value=guoguo>
<INPUT TYPE="button" NAME="bb " value=guoguo>將網頁的按鈕使能

<marquee scrollamount=3 οnmοuseοver=this.stop(); οnmοuseοut=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.οnmοusedοwn=sc
document.οndblclick=initialize
</SCRIPT>//雙擊網頁自動跑

<INPUT TYPE="button" οnclick=window.history.back() value=back>後退
<INPUT TYPE="button" οnclick=window.history.forward() value=forward>前進
<INPUT TYPE="button" οnclick=document.location.reload() value=reload>重新整理

document.location="http://aa.com"或者document.location.assign("http://guoguo.com")轉向指定網頁

<SCRIPT LANGUAGE="JavaScript">
var clock_id;
window.οnlοad=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" οnclick="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" οnmοuseοver=this.className='mouseoverbt'; οnmοuseοut=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.οnkeydοwn=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=# οnmοuseοver=showme() οnmοuseοut=hidme() οnmοusemοve=showme() son=hint>dfdfd</a>
<div id=hint style="display:none"></div>
</BODY>
</HTML>
---------------------------------------------------------------------------------------------------------------------
以上是一個完整的顯示hint的程式碼,其思想是當滑鼠停留是將div中的內容顯示在滑鼠出,當滑鼠移出後在將該div隱藏掉

方法一:<body οnlοad="openwen()"> 瀏覽器讀頁面時彈出視窗;
方法二:<body οnunlοad="openwen()"> 瀏覽器離開頁面時彈出視窗;
方法三:用一個連線呼叫:<a href="#" οnclick="openwin()">開啟一個視窗</a>
注意:使用的"#"是虛連線。
方法四:用一個按鈕呼叫:<input type="button" οnclick="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 οnkeydοwn="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 οncοntextmenu="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()" οncοntextmenu="noEffect()">//禁止選擇頁面上的文字來拷貝


οncοntextmenu="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 οnmοuseup="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%" οnclick=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 οnunlοad="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 οnclick="min.Click()"><font face="webdings">0</font></button>//改變按鈕上的圖片
<input type=button  οnclick="document.execCommand('CreateLink','true','true')"> //建立新連線
<input type=button  οnclick="document.execCommand('print','true','true')"> //列印
<input type=button  οnclick="document.execCommand('saveas','true','海娃線上.htm')">//另存為htm
<input type=button  οnclick="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 οnclick=self.close() alt="...關閉">';
contents+='<img src=jet.gif οnclick=self.close() alt="全是關閉">';
contents+='</td></tr></table>';
showModalDialog("about:"+contents+"","","dialogHeight:50px;dialogWidth:250px;help:no;status:no")
document.write(contents);
</SCRIPT>//web對話方塊


<button οnclick="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' οnclick="window.clipboardData.setData('text',document.selection.createRange().text);" value='複製頁面選中的字元'>//將頁面上選中的內容複製到剪貼簿
<INPUT TYPE="text" NAME="">kjhkjhkhkj<INPUT TYPE="button" οnclick="document.execCommand('Copy', 'false', null);">將頁面上選中的內容複製到剪貼簿

<select οnmοuseοver="javascript:this.size=this.length" οnmοuseοut="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" οnclick="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%' οnmοuseοver='javascript:show(this);' οnmοuseοut='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%' οnmοuseοver='javascript:show(this);' οnmοuseοut='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%' οnmοuseοver='javascript:show(this);' οnmοuseοut='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%' οnmοuseοver='javascript:show(this);' οnmοuseοut='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%' οnmοuseοver='javascript:show(this);' οnmοuseοut='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%' οnmοuseοver='javascript:show(this);' οnmοuseοut='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 οnmοuseοver=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 οnclick="this.style.cursor='wait'">//滑鼠為等待形狀

οnkeydοwn="if(event.shiftKey&&event.keyCode==9)event.keyCode=39"//同時按下shift和別的按鈕


opener.fucntion1();//呼叫父視窗的函式


<input type="button" οnclick="alert(code.document.body.innerHTML)" value="檢視">//body的內部html程式碼


<INPUT TYPE='button' οnclick='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"  οnclick="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"  οnclick="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 οnmοusedοwn=if(event.button==1)alert("左鍵");if(event.button==2)alert("右鍵")>//判斷是左鍵還是右鍵被按下


document.write(navigator.userAgent)//獲得作業系統的名稱和瀏覽器的名稱



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



<body οnlοad="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" οnclick="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 οnclick="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 οnmοuseοver="javascript:this.size=this.length" οnmοuseοut="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 οnmοuseοver="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=列印預覽 οnclick="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" οnclick="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.οnmοuseup=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)

利用正規表示式限制網頁表單裡的文字框輸入內容:

用正規表示式限制只能輸入中文:οnkeyup="value=value.replace(/[^/u4E00-/u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/u4E00-/u9FA5]/g,''))"

用正規表示式限制只能輸入全形字元: οnkeyup="value=value.replace(/[^/uFF00-/uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/uFF00-/uFFFF]/g,''))"

用正規表示式限制只能輸入數字:οnkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"

用正規表示式限制只能輸入數字和英文:οnkeyup="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="###" οnclick=document.execCommand("open")>開啟</a>

2、〖使用 記事本 編輯〗命令的實現
[格式]:location.replace("view-source:"+location)
[說明]開啟記事本,在記事本中顯示該網頁的原始碼。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=location.replace("view-source:"+location)>使用 記事本編輯</a>

3、〖另存為〗命令的實現
[格式]:document.execCommand("saveAs")
[說明]將該網頁儲存到本地盤的其它目錄!
[舉例]在<body></body>之間加入:
<a href="###" οnclick=document.execCommand("saveAs")>另存為</a>

4、〖列印〗命令的實現
[格式]:document.execCommand("print")
[說明]當然,你必須裝了印表機!
[舉例]在<body></body>之間加入:
<a href="###" οnclick=document.execCommand("print")>列印</a>

5、〖關閉〗命令的實現
[格式]:window.close();return false
[說明]將關閉本視窗。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=window.close();return false)>關閉本視窗</a>

二、【編輯(E)】選單中的命令的實現

〖全選〗命令的實現
[格式]:document.execCommand("selectAll")
[說明]將選種網頁中的全部內容!
[舉例]在<body></body>之間加入:
<a href="###" οnclick=document.execCommand("selectAll")>全選</a>

三、【檢視(V)】選單中的命令的實現

1、〖重新整理〗命令的實現
[格式]:location.reload() 或 history.go(0)
[說明]瀏覽器重新開啟本頁。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=location.reload()>重新整理</a>
或加入:
<a href="###" οnclick=history.go(0)>重新整理</a>

2、〖原始檔〗命令的實現
[格式]:location.replace("view-source:"+location)
[說明]檢視該網頁的原始碼。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=location.replace("view-source:"+location)>檢視原始檔</a>

3、〖全屏顯示〗命令的實現
[格式]:window.open(document.location, "url", "fullscreen")
[說明]全屏顯示本頁。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=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="###" οnclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夾</a>

五、【工具(T)】選單中的命令的實現

〖internet選項〗命令的實現
[格式]:window.external.showBrowserUI("PrivacySettings",null)
[說明]開啟internet選項對話方塊。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=window.external.showBrowserUI("PrivacySettings",null)>internet選項</a>

六、【工具欄】中的命令的實現

1、〖前進〗命令的實現
[格式]history.go(1) 或 history.forward()
[說明]瀏覽器開啟後一個頁面。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=history.go(1)>前進</a>
或加入:
<a href="###" οnclick=history.forward()>前進</a>

2、〖後退〗命令的實現
[格式]:history.go(-1) 或 history.back()
[說明]瀏覽器返回上一個已瀏覽的頁面。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=history.go(-1)>後退</a>
或加入:
<a href="###" οnclick=history.back()>後退</a>

3、〖重新整理〗命令的實現
[格式]:document.reload() 或 history.go(0)
[說明]瀏覽器重新開啟本頁。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=location.reload()>重新整理</a>
或加入:
<a href="###" οnclick=history.go(0)>重新整理</a>

七、其它命令的實現
〖定時關閉本視窗〗命令的實現
[格式]:settimeout(window.close(),關閉的時間)
[說明]將關閉本視窗。
[舉例]在<body></body>之間加入:
<a href="###" οnclick=settimeout(window.close(),3000)>3秒關閉本視窗</a>


如果大家還整理出其他用Javascript實現的命令,不妨投稿來和大家分享。

【附】為了方便讀者,下面將列出所有例項程式碼,你可以把它們放到一個html檔案中,然後預覽效果。
<a href="###" οnclick=document.execCommand("open")>開啟</a><br>
<a href="###" οnclick=location.replace("view-source:"+location)>使用 記事本編輯</a><br>
<a href="###" οnclick=document.execCommand("saveAs")>另存為</a><br>
<a href="###" οnclick=document.execCommand("print")>列印</a><br>
<a href="###" οnclick=window.close();return false)>關閉本視窗</a><br>
<a href="###" οnclick=document.execCommand("selectAll")>全選</a><br>
<a href="###" οnclick=location.reload()>重新整理</a> <a href="###" οnclick=history.go(0)>重新整理</a><br>
<a href="###" οnclick=location.replace("view-source:"+location)>檢視原始檔</a><br>
<a href="###" οnclick=window.open(document.location,"url","fullscreen")>全屏顯示</a><br>
<a href="javascript:window.external.AddFavorite('http://homepage.yesky.com', '天極網頁陶吧')">新增到收藏夾</a><br>
<a href="###" οnclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夾</a><br>
<a href="###" οnclick=window.external.showBrowserUI("PrivacySettings",null)>internet選項</a><br>
<a href="###" οnclick=history.go(1)>前進1</a> <a href="###" οnclick=history.forward()>前進2</a><br>
<a href="###" οnclick=history.go(-1)>後退1</a> <a href="###" οnclick=history.back()>後退2</a><br>
<a href="###" οnclick=settimeout(window.close(),3000)>3秒關閉本視窗</a><br>



<BODY οnlοad="alert(a1.epass)">
<input type=text name="a1" epass="zhongguo">
</BODY>//給DHTML中的標籤新增一個新的屬性,可以隨意加



<BODY> 此方法是通過XMLHTTP物件從伺服器獲取XML文件,示例如下。
 <input type=button value="載入XML文件" οnclick="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="#" οnclick=document.execCommand("open")>開啟</a>
  2、〖使用 記事本 編輯〗命令的實現
  [格式]:location.replace("view-source:"+location)
  [說明]開啟記事本,在記事本中顯示該網頁的原始碼。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=location.replace("view-source:"+location)>使用 記事本 編輯</a>
  3、〖另存為〗命令的實現
  [格式]:document.execCommand("saveAs")
  [說明]將該網頁儲存到本地盤的其它目錄!
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=document.execCommand("saveAs")>另存為</a>
  4、〖列印〗命令的實現
  [格式]:document.execCommand("print")
  [說明]當然,你必須裝了印表機!
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=document.execCommand("print")>列印</a>
  5、〖關閉〗命令的實現
  [格式]:window.close();return false
  [說明]將關閉本視窗。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=window.close();return false)>關閉本視窗</a>



  二、【編輯(E)】選單中的命令的實現
  〖全選〗命令的實現
  [格式]:document.execCommand("selectAll")
  [說明]將選種網頁中的全部內容!
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=document.execCommand("selectAll")>全選</a>



  三、【檢視(V)】選單中的命令的實現
  1、〖重新整理〗命令的實現
  [格式]:location.reload() 或 history.go(0)
  [說明]瀏覽器重新開啟本頁。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=location.reload()>重新整理</a>
  或加入:<a href="#" οnclick=history.go(0)>重新整理</a>
  2、〖原始檔〗命令的實現
  [格式]:location.replace("view-source:"+location)
  [說明]檢視該網頁的原始碼。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=location.replace("view-source:"+location)>檢視原始檔</a>
  3、〖全屏顯示〗命令的實現
  [格式]:window.open(document.location,"url","fullscreen")
  [說明]全屏顯示本頁。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=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="#" οnclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夾</a>



  五、【工具(T)】選單中的命令的實現
  〖internet選項〗命令的實現
  [格式]:window.external.showBrowserUI("PrivacySettings",null)
  [說明]開啟internet選項對話方塊。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=window.external.showBrowserUI("PrivacySettings",null)>internet選項</a>



  六、【工具欄】中的命令的實現
  1、〖前進〗命令的實現
  [格式]history.go(1) 或 history.forward()
  [說明]瀏覽器開啟後一個頁面。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=history.go(1)>前進</a>
  或加入:<a href="#" οnclick=history.forward()>前進</a>
  2、〖後退〗命令的實現
  [格式]:history.go(-1) 或 history.back()
  [說明]瀏覽器返回上一個已瀏覽的頁面。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=history.go(-1)>後退</a>
  或加入:<a href="#" οnclick=history.back()>後退</a>
  3、〖重新整理〗命令的實現
  [格式]:document.reload() 或 history.go(0)
  [說明]瀏覽器重新開啟本頁。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=location.reload()>重新整理</a>
  或加入:<a href="#" οnclick=history.go(0)>重新整理</a>
  
  七、其它命令的實現
  〖定時關閉本視窗〗命令的實現
  [格式]:settimeout(window.close(),關閉的時間)
  [說明]將關閉本視窗。
  [舉例]在<body></body>之間加入:
  <a href="#" οnclick=settimeout(window.close(),3000)>3秒關閉本視窗</a>



  如果大家還整理出其他用Javascript實現的命令,不妨投稿來和大家分享。
  【附】為了方便讀者,下面將列出所有例項程式碼,你可以把它們放到一個html檔案中,然後預覽效果。
  <a href="#" οnclick=document.execCommand("open")>開啟</a><br>
  <a href="#" οnclick=location.replace("view-source:"+location)>使用 記事本 編輯</a><br>
  <a href="#" οnclick=document.execCommand("saveAs")>另存為</a><br>
  <a href="#" οnclick=document.execCommand("print")>列印</a><br>
  <a href="#" οnclick=window.close();return false)>關閉本視窗</a><br>
  <a href="#" οnclick=document.execCommand("selectAll")>全選</a><br>
  <a href="#" οnclick=location.reload()>重新整理</a> <a href="#" οnclick=history.go(0)>重新整理</a><br>
  <a href="#" οnclick=location.replace("view-source:"+location)>檢視原始檔</a> <br>
  <a href="#" οnclick=window.open(document.location,"url","fullscreen")>全屏顯示</a> <br>
  <a href="java script:window.external.AddFavorite("http://homepage.yesky.com", "天極網頁陶吧")">新增到收藏夾</a> <br>
  <a href="#" οnclick=window.external.showBrowserUI("OrganizeFavorites",null)>整理收藏夾</a> <br>
  <a href="#" οnclick=window.external.showBrowserUI("PrivacySettings",null)>internet選項</a> <br>
  <a href="#" οnclick=history.go(1)>前進1</a> <a href="#" οnclick=history.forward()>前進2</a><br>
  <a href="#" οnclick=history.go(-1)>後退1</a> <a href="#" οnclick=history.back()>後退2</a><br>
  <a href="#" οnclick=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="<< 第一條記錄"     οnclick="theXMLisland.recordset.moveFirst()">
  <input id="prev" TYPE=button value="<上一條記錄"   οnclick="theXMLisland.recordset.movePrevious()"> 
  <input id="next" TYPE=button value="下一條記錄>" οnclick="theXMLisland.recordset.moveNext()"> 
  <input id="last" TYPE=button value="最後一條記錄>>" οnclick="theXMLisland.recordset.moveLast()">&nbsp; 
  <input id="Add" TYPE=button value="新增新記錄" οnclick="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.οnclick=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 οnmοuseοver="this.style.zoom='200%'" οnmοuseοut="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:" οnclick="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='複製貼上' οnclick="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" οnerrοr="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 οnblur="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 οnblur="if(/[^a-zA-Z]/g.test(this.value))alert('有錯')">
  4.2 判斷字元由字母和數字組成。
      <input οnblur="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 οnlοad="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(οnmοuseοut=οnmοuseup=function(){this.style.borderStyle='outset'}, οnmοusedοwn=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 οnclick='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' οndblclick=/"Max.innerText=Max.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();/" οnmοuseup='parent.drag_up(event)' οnmοusemοve='parent.drag_move(event)' οnmοusedοwn='parent.drag_down(event)' onselectstart='return false' οncοntextmenu='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  οnclick=/"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   οnclick='parent.New_CW.hide();parent.blur()' style=/""+CSStext+"font-family:Webdings;/" title='Minimum'>0</span>";
temp += "<span id=Max   οnclick=/"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 οnclick='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">

禁止貼上

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

禁止複製

本文字框禁止複製: 
語法:οncοpy="return false;" oncut="return false;"
範例:<input name="textfield" type="text" value="不能複製裡面的字" οncοpy="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 οnclick=ShowDisableObject(Show01); type=button value=Disable> <INPUT id=Button1 οnclick=ShowBlankObject(Show01); type=button value=Blank name=Button1> <INPUT id=Button2 οnclick=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"
οnclick="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"
οnclick="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 οnclick=nextYear("+The_Year+","+The_Month+")  style='cursor:hand'>&gt;&gt;</td>";
var prevYearTd="<td width=0 οnclick=prevYear("+The_Year+","+The_Month+")  style='cursor:hand'>&lt;&lt;</td>";
var nextMonthTd="<td width=0 οnclick=nextMonth("+The_Year+","+The_Month+")  style='cursor:hand'>&gt;&gt;</td>";
var prevMonthTd="<td width=0 οnclick=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' οnclick=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. οncοntextmenu="window.event.returnvalue=false" 將徹底遮蔽滑鼠右鍵
<table border οncοntextmenu=return(false)><td>no</table> 可用於Table

2. <body onselectstart="return false"> 取消選取、防止複製

3. οnpaste="return false" 不準貼上

4. οncοpy="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=檢視網頁原始碼
οnclick="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" οnfοcus="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=最小化 οnclick=hh1.Click()>
<input type=button value=最大化 οnclick=hh2.Click()>
<input type=button value=關閉 οnclick=hh3.Click()>
本例適用於IE

17.遮蔽功能鍵Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift鍵!"; //可以換成ALT CTRL
}
document.οnkeydοwn=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 οnblur="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 οnlοad="top.resizeTo(300,200);">
開啟頁面的位置<body οnlοad="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" οnclick="checkme()">
</BODY></HTML>

34.指令碼永不出錯
<SCRIPT LANGUAGE="javascript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>

35.ENTER鍵可以讓游標移到下一個輸入框
<input οnkeydοwn="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

οnclick=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

οnerrοr=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="圖片的路徑" οnmοuseοut=stoprattle(this) οnmοuseοver=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 οnlοad="openwin()">
…任意的頁面內容…
</body>
</html>
這裡定義了一個函式openwin(),函式內容就是開啟一個視窗。在呼叫它之前沒有任何用途。
怎麼呼叫呢?
方法一:<body οnlοad="openwin()"> 瀏覽器讀頁面時彈出視窗;
方法二:<body οnunlοad="openwin()"> 瀏覽器離開頁面時彈出視窗;
方法三:用一個連線呼叫:
<a href="#" οnclick="openwin()">開啟一個視窗</a>
注意:使用的“#”是虛連線。
方法四:用一個按鈕呼叫:
<input type="button" οnclick="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 οnmοuseοut=low(this) οnmοuseοver=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.οnmοusedοwn=sc
document.οndblclick=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="#" οnclick="closes.Click();">關閉視窗無提示</a>
</body>
</html>

34,禁止滑鼠右鍵檢視網頁原始碼。
<SCRIPT language=javascript>
function click()
{if (event.button==2) {alert(`你好,歡迎光臨!`) }}
document.οnmοusedοwn=click
</SCRIPT>
補充說明:
滑鼠完全被封鎖,可以遮蔽滑鼠右鍵和網頁文字。
< body οncοntextmenu="return false" οndragstart="return false" onselectstart="return false">

35,通過按鈕來檢視網頁原始碼。
<input type="BUTTON" value="檢視原始碼" onClick= `window.location = "view-source:" + window.location.href` name="BUTTON">

36,怎麼用文字聯結實現按鈕的SUBMIT功能?
<a href="#" οnclick="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. οncοntextmenu="window.event.returnvalue=false" 將徹底遮蔽滑鼠右鍵
<table border οncοntextmenu=return(false)><td>no</table> 可用於Table

2. <body onselectstart="return false"> 取消選取、防止複製

3. οnpaste="return false" 不準貼上

4. οncοpy="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=檢視網頁原始碼
οnclick="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" οnfοcus="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=最小化 οnclick=hh1.Click()>
<input type=button value=最大化 οnclick=hh2.Click()>
<input type=button value=關閉 οnclick=hh3.Click()>
本例適用於IE

17.遮蔽功能鍵Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift鍵!"; //可以換成ALT CTRL
}
document.οnkeydοwn=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 οnblur="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 οnlοad="top.resizeTo(300,200);">
開啟頁面的位置<body οnlοad="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" οnclick="checkme()">
</BODY></HTML>

34.指令碼永不出錯
<SCRIPT LANGUAGE="javascript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>

35.ENTER鍵可以讓游標移到下一個輸入框
<input οnkeydοwn="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

οnclick=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

οnerrοr=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="圖片的路徑" οnmοuseοut=stoprattle(this) οnmοuseοver=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 οnlοad="openwin()">
…任意的頁面內容…
</body>
</html>
這裡定義了一個函式openwin(),函式內容就是開啟一個視窗。在呼叫它之前沒有任何用途。
怎麼呼叫呢?
方法一:<body οnlοad="openwin()"> 瀏覽器讀頁面時彈出視窗;
方法二:<body οnunlοad="openwin()"> 瀏覽器離開頁面時彈出視窗;
方法三:用一個連線呼叫:
<a href="#" οnclick="openwin()">開啟一個視窗</a>
注意:使用的“#”是虛連線。
方法四:用一個按鈕呼叫:
<input type="button" οnclick="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 οnmοuseοut=low(this) οnmοuseοver=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.οnmοusedοwn=sc
document.οndblclick=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="#" οnclick="closes.Click();">關閉視窗無提示</a>
</body>
</html>

34,禁止滑鼠右鍵檢視網頁原始碼。
<SCRIPT language=javascript>
function click()
{if (event.button==2) {alert(`你好,歡迎光臨!`) }}
document.οnmοusedοwn=click
</SCRIPT>
補充說明:
滑鼠完全被封鎖,可以遮蔽滑鼠右鍵和網頁文字。
< body οncοntextmenu="return false" οndragstart="return false" onselectstart="return false">

35,通過按鈕來檢視網頁原始碼。
<input type="BUTTON" value="檢視原始碼" onClick= `window.location = "view-source:" + window.location.href` name="BUTTON">

36,怎麼用文字聯結實現按鈕的SUBMIT功能?
<a href="#" οnclick="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 οnblur="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 οnlοad="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>
超連結去虛線邊框
在連結中加上οnfοcus="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;
}

列表/選單
οnchange="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" οnlοad="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 οncοntextmenu="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 οncοntextmenu="return false" οndragstart="return false" onselectstart ="return false" οnselect="document.selection.empty()" οncοpy="document.selection.empty()" onbeforecopy="return false"οnmοuseup="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=# οnclick="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後面插入οnmοuseοver="javascript:this.bgColor='#57AE00'" οnmοuseοut="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 或以後版本。

 

 



 

相關文章