主頁(yè) > 知識(shí)庫(kù) > ASP與數(shù)據(jù)庫(kù),有用的代碼(轉(zhuǎn)貼,摘貼)

ASP與數(shù)據(jù)庫(kù),有用的代碼(轉(zhuǎn)貼,摘貼)

熱門(mén)標(biāo)簽:Linux服務(wù)器 Mysql連接數(shù)設(shè)置 電子圍欄 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 銀行業(yè)務(wù) 阿里云 服務(wù)器配置 團(tuán)購(gòu)網(wǎng)站
ASP與數(shù)據(jù)庫(kù)

 ASP與數(shù)據(jù)庫(kù)運(yùn)用:密碼驗(yàn)證 
        Microsoft 的大作ASP(Active Server 
      Pages)以其易學(xué)易用、擴(kuò)充性好、功能多而強(qiáng)等優(yōu)點(diǎn)正掀起一場(chǎng)新的web編程革命(從嚴(yán)格意義上講,編寫(xiě)asp并不是編程),它以令人吃驚的發(fā)展和普及速度大有取代由perl等語(yǔ)言編寫(xiě)的CGI(Common 
      Gateway Interface,通用網(wǎng)關(guān)接口) 的勢(shì)頭?;趙eb 
      page方式的web管理模式已經(jīng)成為潮流,看看現(xiàn)在的網(wǎng)管們,有誰(shuí)不會(huì)asp的編寫(xiě)呢?要管理?那你可能就要用到我這里要說(shuō)的“密碼驗(yàn)證”了。簡(jiǎn)單地說(shuō),密碼驗(yàn)證就是首先判斷你是不是有登錄權(quán)限,如果有,就繼續(xù),否則,哼哼……。什么?你到現(xiàn)在還不知道ASP是什么東東?“該程序執(zhí)行了非法操作,即將被關(guān)閉。如仍有問(wèn)題,請(qǐng)與程序供應(yīng)商聯(lián)系?!?---------系統(tǒng)語(yǔ)
        下面,我們就來(lái)看看實(shí)現(xiàn)密碼驗(yàn)證的ASP需要些什么吧。
        一、 ASP運(yùn)行環(huán)境:
        Windows 95/98單機(jī)平臺(tái):PWS (Personal Web Server)4.0 、windows NT 
      4.0/5.0服務(wù)器平臺(tái):IIS(Internet Information Server )Service Pack 3 及其以上版本)
        NT workstation 4.0 工作站平臺(tái):PWS(Personal Web Server )NT 
      workstation版及最新版的IE瀏覽器。
        二、 用于制作ASP的軟件
        Windows FrontPage 98/2000 、Dreamweaver 3.0 ,如果這些軟件你都沒(méi)有,那你就用windows 
      中的Notepad 
      當(dāng)一次“代碼編寫(xiě)狂”吧。不過(guò)ASP中很多代碼仍是需要我們手工編寫(xiě)大量代碼的,用專(zhuān)用的網(wǎng)頁(yè)制作軟件只不過(guò)是偷一丁點(diǎn)懶而已。
        三、 用哪一種數(shù)據(jù)庫(kù)作為儲(chǔ)存用戶(hù)資料(用戶(hù)名及密碼)的數(shù)據(jù)庫(kù)呢?
        SQL Server、Microsoft Access 
      97/2000等都可以。本人建議你使用Access,因?yàn)槟憧赡軐?duì)它比較熟悉,一旦有問(wèn)題,解決起來(lái)比較容易,更深的原因是:Microsoft 
      Access相對(duì)于其它非服務(wù)器等級(jí)的數(shù)據(jù)庫(kù)執(zhí)行的效率要高得多。
        好了,廢話說(shuō)了這么多,可能你早已經(jīng)不耐煩了。不過(guò),這對(duì)于一些ASP的初學(xué)者可能還是有幫助的,對(duì)于這部分讀者,你們可能還得要看看關(guān)于ASP方面的書(shū)籍或網(wǎng)站來(lái)增加你對(duì)ASP基本語(yǔ)法的了解。
        讓我們一步一步來(lái)做這個(gè)密碼驗(yàn)證吧,我采用的是Windows 98 + PWS 4.0平臺(tái),IE 
      5.0瀏覽器,網(wǎng)頁(yè)制作軟件:FrontPage 2000. Go!
        一、創(chuàng)建用戶(hù)密碼數(shù)據(jù)庫(kù)
        先用Access建立一個(gè)用戶(hù)密碼數(shù)據(jù)庫(kù),建立字段名id和psd,并添加值.如:id的值我設(shè)為:admin,psd的值為:www,當(dāng)然,你還可以繼續(xù)添加用戶(hù)id及psd,完成后保存為:psd.mdb。
        二、編寫(xiě)psd.asp(用戶(hù)登錄界面頁(yè),完成驗(yàn)證的功臣就是它了)及l(fā)og.asp(成功登錄后顯示的頁(yè)面)。在編寫(xiě)之前,我們來(lái)分析一下常見(jiàn)的用戶(hù)登錄界面,比如說(shuō)你想收取基于web 
      page方式免費(fèi)郵件箱的登錄界面:管理用戶(hù)登錄的文件名常常為log.*,開(kāi)始登錄時(shí)是這個(gè)文件,登錄完成后瀏覽器的地址欄中還是顯示的這個(gè)文件名,這是怎么回事兒呢?用ASP的方法來(lái)講,原來(lái),用戶(hù)登錄的文件被包含在登錄完成后的文件中。以我現(xiàn)在要講的這個(gè)例子來(lái)說(shuō),psd.asp就是被包含在log.asp中了。用戶(hù)登錄時(shí)看到的文件名將是:log.asp,而log.asp要求系統(tǒng)先執(zhí)行psd.asp,通過(guò)驗(yàn)證之后才看到真正的log.asp網(wǎng)頁(yè)。對(duì)了!實(shí)際上密碼驗(yàn)證的關(guān)鍵在psd.asp。在你讀完本文后,你會(huì)深深體會(huì)這一點(diǎn)。既然psd.asp文件是關(guān)鍵,那我們就先來(lái)看看psd.asp是怎么寫(xiě)的。
        運(yùn)行FrontPage新建一個(gè)文件,并保存為:psd.asp(在FrontPage 的保存類(lèi)型中選取“Active Server 
      Pages”)。在FrontPage 
      左下角選取“HTML”先在它的頂部進(jìn)行ASP源代碼的編寫(xiě),內(nèi)容如下(以下源代碼中凡出現(xiàn)“‘……”的均為注釋): 
        %
        function checkPwd(id,psd) '檢測(cè)用戶(hù)id及密碼
        dim conn,param,rs 
        set conn=server.createobject("adodb.connection") '創(chuàng)建數(shù)據(jù)庫(kù)連接對(duì)象conn
        param="driver={microsoft access driver (*.mdb)}" 
      ‘指定數(shù)據(jù)庫(kù)驅(qū)動(dòng)程序,不可省略寫(xiě)為“access diver(*.mdb)”
        conn.open param  ";dbq="  server.mappath("psd.mdb") 
      '用指定的數(shù)據(jù)庫(kù)驅(qū)動(dòng)程序打開(kāi)數(shù)據(jù)庫(kù),并指定數(shù)據(jù)路徑
        sql="select*from psd where id='"  id  "' and psd='"  psd  "'" 
      ‘定義sql從數(shù)據(jù)庫(kù)中讀取id及psd的值,本行中的第一個(gè)psd是指數(shù)據(jù)庫(kù)名,以后的psd是指psd.mdb中的psd字段。
        set rs=conn.execute(sql) '打開(kāi)數(shù)據(jù)庫(kù)
        if rs.eof then 
        checkpwd=false 
        else 
        checkpwd=true 
        end if 
        end function 
      ‘以上幾句判斷是否已經(jīng)讀完數(shù)據(jù)庫(kù)中的記錄,如果沒(méi)有,就向后讀,如果已經(jīng)完成,則驗(yàn)證用戶(hù)名及密碼。如果驗(yàn)證通過(guò),則為true,反之為flase
        %> 
        % 
        if isEmpty(session("passed")) then session("passed")=false 
      '判斷用戶(hù)輸入信息 
        id=request("id") ‘獲取用戶(hù)id(用戶(hù)名)
        psd=request("psd") ‘獲取用戶(hù)psd(密碼)
        if id="" or psd="" then 
        response.write"請(qǐng)輸入您的登錄名及密碼。" '如果用戶(hù)沒(méi)有輸入完整的信息,返回出錯(cuò)信息。 
        elseif not checkpwd(id,psd) then 
        response.write"用戶(hù)名或密碼錯(cuò)誤!br>請(qǐng)檢查你的用戶(hù)名及密碼然后再試一次!" 
      ‘如果用戶(hù)已經(jīng)輸入完整信息,但輸入錯(cuò)誤也返回出錯(cuò)信息。
        else session("passed")=true 
        end if
        if not session("passed") then%> 
      ‘用戶(hù)輸入的信息完全正確并驗(yàn)證通過(guò),以下開(kāi)始編寫(xiě)html代碼,做一個(gè)用戶(hù)登錄界面。
        html>
        head>
        meta http-equiv="Content-Type" content="text/html; 
      charset=gb2312">
        title>請(qǐng)您輸入您的用戶(hù)名及密碼!/title>
        /head>
        body bgcolor="#000000" text="#FFFFFF">
        p align="center">  
        p align="center"> /p> 
        p align="center">b>font face="黑體" 
      size="6">用戶(hù)登錄首頁(yè)/font>/b>/p> 
        p align="center"> /p> 
        form method="POST" 
      action="%=request.serverVariables("psd.mdb")%>"> 
        table border="0" width="100%" cellspacing="0" cellpadding="0"> 
        tr> 
        td width="41%" align="right">用戶(hù)名:/td> 
        td width="59%">input type="text" name="id" size="20" 
      value="%=id%>">/td> 
        /tr> 
        tr> 
        td width="41%" align="right"> 密 碼:/td> 
        td width="59%">input type="password" name="psd" size="20" 
      value="%=psd%>">/td> 
        /tr> 
        tr> 
        td width="41%"> /td> 
        td width="59%"> /td> 
        /tr> 
        /table> 
        p align="center">input type="submit" value="提交" name="B1">input 
      type="reset" value="清除" name="B1">/p> 
        /form> 
        %response.end 
        end if %> ‘驗(yàn)證過(guò)程結(jié)束,進(jìn)入加密網(wǎng)頁(yè)。
        /body> 
        /html> 
        完成了psd.asp的編寫(xiě),可能你早已經(jīng)迫不及待地想知道log.asp怎么編寫(xiě)了吧。讓我們繼續(xù)吧!
        Log.asp的內(nèi)容:
        !--#include file="psd.asp"--> 
      ‘在log.asp源代碼中的頂部輸入這句,作用就是在系統(tǒng)執(zhí)行l(wèi)og.asp之前先執(zhí)行psd.asp啦!
        html>
        head>
        title>用戶(hù)驗(yàn)證通過(guò),您已經(jīng)成功登錄系統(tǒng)/title>
        /head>
        body>center>p>p>p>p>用戶(hù)驗(yàn)證通過(guò),您已經(jīng)成功登錄!br>
        現(xiàn)在你可以進(jìn)行你想要的操作了。如果你有什么問(wèn)題,請(qǐng)來(lái)信Emaila 
      href="mailto:kanwo@163.net?subject=問(wèn)你幾個(gè)關(guān)于密碼驗(yàn)證的問(wèn)題">kanwo@163.net/a>/center>
        /body>
        /html>
        呵呵……手寫(xiě)了這么多,還受得了吧。你在編寫(xiě)完成之后,可以移植到其它平臺(tái)上,比如Windows 
      NT。最后,將你做的這兩個(gè)asp文件及psd.mdb數(shù)據(jù)庫(kù)放在同一個(gè)目錄下(該目錄必須在PWS或IIS中有www服務(wù)),比如:c:\inetpub\wwwroot\。然后,在確保你的PWS或IIS在運(yùn)行的情況下,在你們IE瀏覽器的地址欄中輸入http://127.0.0.1/log.asp,看看,會(huì)有什么!(如果你在登錄過(guò)程中聽(tīng)到你的硬盤(pán)在響,可別嚇著了喲!)

 


q 文 章 點(diǎn) 評(píng)       3 篇


>>上篇文章:ASP技術(shù)訪問(wèn)WEB數(shù)據(jù)庫(kù)  
>>下篇文章:制作有管理功能的ASP留言板  



 

第三招:控制你的彈出窗口只彈出一次(如果每進(jìn)一次,刷新一次就彈出你不覺(jué)得很煩和麻煩嗎?)有什么好的辦法嗎?
那是當(dāng)然的啊,我們現(xiàn)在只要使用cookie來(lái)控制就能實(shí)現(xiàn)這樣的要求了。
首先,你需把將如下代碼加入到頁(yè)面HTML的<HEAD>和</HEAD>之間:

<script>
.function openwin(){
.window.open("pop1.html","","width=120,height=240")
.}
.function get_cookie(Name) {
.var search = Name + "="
.var returnvalue = "";
.if (document.cookie.length > 0) {
.offset = document.cookie.indexOf(search)
.if (offset != -1) {
.offset += search.length
.end = document.cookie.indexOf(";", offset);
.if (end == -1)
.end = document.cookie.length;
.returnvalue=unescape(document.cookie.substring(offset, end))
. }
. }
.return returnvalue;
. }
.function loadpopup(){ //*控制彈出窗口的函數(shù)喲,你要使用他的啊
.if (get_cookie('popped')==''){
.openwin()
.document.cookie="popped=yes"
. }
.}
.//-->
</script>

 然后,用<body onload="loadpopup()">替換頁(yè)面中原來(lái)的<BODY>這一句就行的了。


》》》》》》》》》》》》》》》》》》》》》》----------------------------------
在提交帖之后:
%
if Response.Cookies("time")>"" then
  if DateDiff('s',Response.Cookies("time"),now())20   '隔20s才能再發(fā)帖
    Response.Write "script>alert('不能頻繁發(fā)帖');window.location=history.go(-1)/script>"
    response.End
  end if
end if
Response.Cookies("time")=now()
……             '將帖子入庫(kù)
----------------------------------------------------------

                    ASP項(xiàng)目中的公共翻頁(yè)模塊:

在大型的ASP項(xiàng)目中,很多的頁(yè)面都涉及到翻頁(yè)功能。如果每個(gè)頁(yè)面都寫(xiě)一個(gè)翻頁(yè)的程序的話,這樣的工作即降低了工作效率,也不利于工程的模塊化,不能使代碼重用。因此,把翻頁(yè)這樣的功能模塊化是很有必要的。
設(shè)計(jì)方法: 
1、調(diào)用該模塊時(shí),只需要傳遞記錄集和每頁(yè)顯示的記錄的條數(shù); 
2、可以點(diǎn)擊鏈接進(jìn)行翻頁(yè),也可以直接輸入頁(yè)碼,回車(chē)后翻頁(yè); 
3、不要考慮文件名,程序的每次翻頁(yè)都能在當(dāng)前頁(yè)面。 
想清楚了上面3個(gè)問(wèn)題,我們的公共翻頁(yè)模塊就可以動(dòng)手了。 

'+++++++++++++++++++++++++++++++++++++ 
'◆模塊名稱(chēng): 公共翻頁(yè)模塊 
'◆文 件 名: TurnPage.asp 
'◆傳入?yún)?shù): Rs_tmp (記錄集), PageSize (每頁(yè)顯示的記錄條數(shù)) 
'◆輸 出: 記錄集翻頁(yè)顯示功能 
'+++++++++++++++++++++++++++++++++++++ 

Sub TurnPage(ByRef Rs_tmp,PageSize) 'Rs_tmp 記錄集  PageSize 每頁(yè)顯示的記錄條數(shù); 
Dim TotalPage '總頁(yè)數(shù) 
Dim PageNo '當(dāng)前顯示的是第幾頁(yè) 
Dim RecordCount '總記錄條數(shù) 
Rs_tmp.PageSize = PageSize 
RecordCount = Rs_tmp.RecordCount 
TotalPage = INT(RecordCount / PageSize * -1)*-1 
PageNo = Request.QueryString ("PageNo") 
'直接輸入頁(yè)數(shù)跳轉(zhuǎn); 
If Request.Form("PageNo")>"" Then PageNo = Request.Form("PageNo") 
'如果沒(méi)有選擇第幾頁(yè),則默認(rèn)顯示第一頁(yè); 
If PageNo = "" then PageNo = 1 
If RecordCount > 0 then 
Rs_tmp.AbsolutePage = PageNo 
End If 

'獲取當(dāng)前文件名,使得每次翻頁(yè)都在當(dāng)前頁(yè)面進(jìn)行; 
Dim fileName,postion 
fileName = Request.ServerVariables("script_name") 
postion = InstrRev(fileName,"/")+1 
'取得當(dāng)前的文件名稱(chēng),使翻頁(yè)的鏈接指向當(dāng)前文件; 
fileName = Mid(fileName,postion) 
%> 
table border=0 width='100%'> 
tr> 
td align=left> 總頁(yè)數(shù):font color=#ff3333>%=TotalPage%>/font>頁(yè) 
  當(dāng)前第font color=#ff3333>%=PageNo%>/font>頁(yè)/td> 
td align="right"> 
%If RecordCount = 0 or TotalPage = 1 Then 
Response.Write "首頁(yè)|前頁(yè)|后頁(yè)|末頁(yè)" 
Else%> 
a href="%=fileName%>?PageNo=1">首頁(yè)|/a> 
%If PageNo - 1 = 0 Then 
Response.Write "前頁(yè)|" 
Else%> 
a href="%=fileName%>?PageNo=%=PageNo-1%>">前頁(yè)|/a> 
%End If 

If PageNo+1 > TotalPage Then 
Response.Write "后頁(yè)|" 
Else%> 
a href="%=fileName%>?PageNo=%=PageNo+1%>">后頁(yè)|/a> 
%End If%> 

a href="%=fileName%>?PageNo=%=TotalPage%>">末頁(yè)/a> 
%End If%>/td> 
td width=95>轉(zhuǎn)到第 
%If TotalPage = 1 Then%> 
input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3"> 
%Else%> 
input type=text name=PageNo size=3 value="" title=請(qǐng)輸入頁(yè)號(hào),然后回車(chē)> 
%End If%>頁(yè) 
/td> 
/tr> 
/table> 
%End Sub%> 

當(dāng)然,大家可以把翻頁(yè)的鏈接做成圖片按鈕,這樣的話也面就更加美觀了。 

調(diào)用方法: 
1、在程序開(kāi)始或要使用翻頁(yè)的地方包含翻頁(yè)模塊文件; 
2、定義變量:RowCount,每頁(yè)顯示的記錄條數(shù) 
3、調(diào)用翻頁(yè)過(guò)程:Call TurnPage(記錄集,RowCount) 
4、在Do While 循環(huán)輸出記錄集的條件中加上" RowCount > 0 " 條件 
5、在循環(huán)結(jié)束 "Loop前" 加上: RowCount = RowCount - 1 

'----------------------------------------------------- 
調(diào)用范例: 
文件名:News.asp 


Dim Conn,Rs_News 
Set Conn = server.CreateObject("ADODB.CONNECTION") 
Conn.Open "cpm","cpm","cpm" 

Dim Sql 
Sql = "Select * from News" 
Set Rs_News = Server.CreateObject("ADODB.RECORDSET") 
Rs_News.Open Sql,Conn,1,3 '獲取的記錄集 

'公共翻頁(yè)模塊開(kāi)始%> 
!--#include file=../Public/TurnPage.asp--> 

Dim RowCount 
RowCount = 10 '每頁(yè)顯示的記錄條數(shù) 
Call TurnPage(Rs_News,RowCount) 
'公共翻頁(yè)模塊結(jié)束%> 

table width=100%> 
tr> 
td>新聞編號(hào)/td> 
td>新聞標(biāo)題/td> 
td>發(fā)布日期/td> 
tr> 

If Not Rs_News.eof 
Do while Not Rs_News.eof and RowCount>0 
%> 
tr> 
td>%=Rs_News("ID")%>/td> 
td>%=Rs_News("Name")%>/td> 
td>%=Rs_News("Date")%>/td> 
tr> 

RowCount = RowCount - 1 
Rs_News.MoveNext 
Loop 
End If 
%>  
(出處:www.dev-club.com)

 
 --------------------------------------------------------------------
 在提交帖之后:
%
if Response.Cookies("time")>"" then
  if DateDiff('s',Response.Cookies("time"),now())20   '隔20s才能再發(fā)帖
    Response.Write "script>alert('不能頻繁發(fā)帖');window.location=history.go(-1)/script>"
    response.End
  end if
end if
Response.Cookies("time")=now()
……             '將帖子入庫(kù)


---------------------------------
怎樣去除執(zhí)行window.close()后彈出的‘是否關(guān)閉窗口'對(duì)話框

self.opener=null;
self.close();
但是只能在IE5.5  或IE6.0上用

最小化、最大化、關(guān)閉窗口
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>
-------------------------------------------------------
我的下拉框中又兩個(gè)選項(xiàng),當(dāng)選擇第一個(gè)時(shí),出現(xiàn)一個(gè)用戶(hù)輸入頁(yè)面,但是有一部分input框是不要用戶(hù)填寫(xiě)的。當(dāng)選擇第二項(xiàng)時(shí),出現(xiàn)地頁(yè)面是全部都要填寫(xiě)的。不知道該如何實(shí)現(xiàn)?
select onchange="text1.disabled=this.selectedIndex==0">
option>False/option>
option>True/option>
/select>
input type=text id=text1 disabled>
------------------------------------------------------------------>>>>>>>>>>>>>>
我的目的是:打開(kāi)一個(gè)web頁(yè)(就稱(chēng)為'原頁(yè)' 吧),點(diǎn)擊一個(gè)按鈕彈出一個(gè)小窗口(原頁(yè)不關(guān),小窗口最好可以拖動(dòng)),在小窗口里提交一個(gè)表單到原頁(yè)。有什么方法可以實(shí)現(xiàn)?
給『原頁(yè)』一個(gè)name屬性,表單的target指向它
script>
this.name = "bencalie";
newwin = window.open("","","width=400,height=200");
newwin.document.write("form action='test.cgi' target='bencalie'>input type=submit>/form>");
/script>

==============================================
沒(méi)有邊框的窗口::;;;;

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 =  "http://www.cnbruce.com/bluebook/";
var  New_CW =  window.createPopup();
var  CW_Body =  New_CW.document.body;
var  content =  "";
var  CSStext =  "margin:1px;color:black;  border:2px  outset;border-style:expression(onmouseout=onmouseup=function(){this.style.borderStyle='outset'},  onmousedown=function(){if(event.button!=2)this.style.borderStyle='inset'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursor:Default;";

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

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

setTimeout("insert_content()",1000);

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

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

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

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

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

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

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

/SCRIPT>
/HTML>
============================================================>>>>>>>>>>>>>>>>>>>>>


還有圖片的“黑白轉(zhuǎn)彩色”
SCRIPT>
function  doTrans(filterCode)  
{
imgObj.filters[0].apply();
oImg.style.filter  =  filterCode
imgObj.filters[0].play();
}
/SCRIPT>

SPAN  id=imgObj  
onmouseleave='doTrans("gray")'  
style="FILTER:  progid:DXImageTransform.Microsoft.Fade(Overlap=1.00);  WIDTH:  1px"  
onmouseenter='doTrans("")'>
IMG  id=oImg  style="FILTER:  gray"  src="http://www.cnbruce.com/images/cnrose/a.gif">  
/SPAN>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
模擬office菜單:::
:::::::::::::
style  type="text/css">
*  {  font-size:  12px;  }
body  {  margin:  0px;  }
/style>

script  language="JavaScript">
//  Office  XP  菜單

var  sub_display  =  false;

//  顏色數(shù)組說(shuō)明:此數(shù)組儲(chǔ)存菜單各部份顏色樣式,可以改變顏色值達(dá)到改變樣式的效果
//  值依次為:高亮背景色,  高亮邊框色,  菜單欄背景色,  子菜單背景色,  子菜單邊框色,  子菜單標(biāo)題色,  子菜單陰影色

var  color  =  ['#B6BDD2',  '#0A246A',  '#D4D0C8',  '#F8F8F8',  '#666666',  '#DBD8D1',  '#DDDDDD'];

//  菜單數(shù)組說(shuō)明:此數(shù)組儲(chǔ)存各菜單數(shù)據(jù)
//  值依次為:
//  1.  主菜單名稱(chēng),  下拉菜單右延空白長(zhǎng)度
//  2.  第1個(gè)子菜單名稱(chēng),  鏈接地址
//  3.  第2個(gè)子菜單名稱(chēng),  鏈接地址
//  4.  ......

var  menu  =  new  Array();
menu[0]  =  [['菜單一',  50],  ['1111',  '1.htm'],  ['2222',  '2.htm'],  ['3333',  '3.htm']];
menu[1]  =  [['菜單二',  50],  ['1111',  '1.htm'],  ['2222',  '2.htm'],  ['3333',  '3.htm']];
menu[2]  =  [['菜單三',  50],  ['1111',  '1.htm'],  ['2222',  '2.htm'],  ['3333',  '3.htm']];
menu[3]  =  [['菜單四',  50],  ['1111',  '1.htm'],  ['2222',  '2.htm'],  ['3333',  '3.htm']];
menu[4]  =  [['菜單五',  50],  ['1111',  '1.htm'],  ['2222',  '2.htm'],  ['3333',  '3.htm']];
menu[5]  =  [['菜單六',  50],  ['1111',  '1.htm'],  ['2222',  '2.htm'],  ['3333',  '3.htm']];


document.write('table  width="100%"  cellspacing="0"  cellpadding="0"  style="background-color:  '  +  color[2]  +  ';  border-left:  1px  #F4F4F4  solid;  border-top:  1px  #F4F4F4  solid;  border-right:  1px  #999999  solid;  border-bottom:  1px  #999999  solid;"  onSelectStart="return  false;"  onContextMenu="return  false;">tr>td  width="5">img  width="5"  height="1">/td>td>table  cellspacing="0"  cellpadding="2">tr>');
for  (var  i=0;  imenu.length;  i++)
document.write('td  style="border:  1px  '  +  color[2]  +  '  solid;  cursor:  default;"  onClick="Menu_Click(this,  '  +  i  +  ')"  onMouseOver="Menu_Over(this,  '  +  i  +  ')"  onMouseOut="Menu_Out(this,  '  +  i  +  ')">nobr>img  width="10"  height="1">'  +  menu[i][0][0]  +  'img  width="10"  height="1">/nobr>/td>');
document.write('/td>/tr>/table>/tr>/table>');

for  (var  i=0;  imenu.length;  i++)  {
        document.write('table  id="subMenu"  cellspacing="0"  cellpadding="0"  onSelectStart="return  false;"  onContextMenu="return  false;"  style="position:  absolute;  display:  none;  top:  1px;  border-left:  1px  '  +  color[4]  +  '  solid;  border-bottom:  1px  '  +  color[4]  +  '  solid;  cursor:  default;  filter:progid:dximagetransform.microsoft.dropshadow(color='  +  color[6]  +  ',offx=3,offy=3,positive=true)">tr>td  style="border-top:  1px  '  +  color[4]  +  '  solid;  border-right:  1px  '  +  color[4]  +  '  solid;  background-color:  '  +  color[5]  +  ';"  onClick="subMenu_Hide(false)">nobr>img  width="1"  height="2">br>img  width="12"  height="1">'  +  menu[i][0][0]  +  'img  width="12"  height="1">br>img  width="1"  height="3">/nobr>/td>td  style="border-bottom:  1px  '  +  color[4]  +  '  solid;"  onMouseOver="subMenu_Hide(true)">img  width="'  +  menu[i][0][1]  +  '"  height="1">/td>/tr>tr>td  colspan="2"  style="border-right:  1px  '  +  color[4]  +  '  solid;  background-color:  '  +  color[3]  +  ';">table  width="100%"  cellspacing="1"  cellpadding="2"  style="  background-color:  '  +  color[3]  +  '">');
        for  (var  j=1;  jmenu[i].length;  j++)
        document.write('tr>td  style="border:  1px  '  +  color[3]  +  '  solid;"  onMouseOver="subMenu_Over(this)"  onMouseOut="subMenu_Out(this)"  onClick="location.href=\''  +  menu[i][j][1]  +  ''">nobr>nbsp;'  +  menu[i][j][0]  +  '/nobr>/td>/tr>');
        document.write('/td>/tr>/table>/td>/tr>/table>');
}

function  Menu_Over(obj,  s)  {
        if  (sub_display)  {
                subMenu_Show(obj,  s)
        }
        else  {
                obj.style.backgroundColor  =  color[0];
                obj.style.border  =  '1px  '  +  color[1]  +  '  solid';
        }
}

function  Menu_Out(obj)  {
        obj.style.backgroundColor  =  '';
        obj.style.border  =  '1px  '  +  color[2]  +  '  solid';
}

function  Menu_Click(obj,  s)  {
        subMenu_Show(obj,  s)
}

function  subMenu_Over(obj)  {
        obj.style.backgroundColor  =  color[0];
        obj.style.border  =  '1px  '  +  color[1]  +  '  solid';
}

function  subMenu_Out(obj)  {
        obj.style.backgroundColor  =  '';
        obj.style.border  =  '1px  '  +  color[3]  +  '  solid';
}

function  subMenu_Hide(hide)  {
        for  (var  i=0;  isubMenu.length;  i++)
        subMenu[i].style.display  =  'none';
        sub_display  =  hide;
}

function  subMenu_Show(obj,  s)  {
        subMenu_Hide(false);
        subMenu(s).style.posLeft  =  obj.offsetLeft  +  6;
        subMenu(s).style.display  =  '';
        sub_display  =  true;
}

window.onfocus  =  subMenu_Hide;
/script>  
=-=======================-----------------========================================

 

模仿OUTLOOK的菜單:
head>
style  type="text/css">
.titleStyle{
background-color:#3366cc;color:#ffffff;border-top:1px  solid  #FFFFFF;font-size:9pt;cursor:hand;
}
.contentStyle{
background-color:#efefef;color:blue;font-size:9pt;
}

a{
color:blue;
}
body{
font-size:9pt;
}
/style>
/head>
body>
script  language="JavaScript">
!--
  var  layerTop=20;              //菜單頂邊距
  var  layerLeft=30;            //菜單左邊距
  var  layerWidth=140;        //菜單總寬
  var  titleHeight=20;        //標(biāo)題欄高度
  var  contentHeight=200;  //內(nèi)容區(qū)高度
  var  stepNo=10;                  //移動(dòng)步數(shù),數(shù)值越大移動(dòng)越慢

  var  itemNo=0;runtimes=0;
  document.write('span  id=itemsLayer  style="position:absolute;overflow:hidden;border:1px  solid  #efefef;left:'+layerLeft+';top:'+layerTop+';width:'+layerWidth+';">');

  function  addItem(itemTitle,itemContent){
      itemHTML='div  id=item'+itemNo+'  itemIndex='+itemNo+'  style="position:relative;left:0;top:'+(-contentHeight*itemNo)+';width:'+layerWidth+';">table  width=100%  cellspacing="0"  cellpadding="0">'+
              'tr>td  height='+titleHeight+'  onclick=changeItem('+itemNo+')  class="titleStyle"  align=center>'+itemTitle+'/td>/tr>'+
              'tr>td  height='+contentHeight+'  class="contentStyle">'+itemContent+'/td>/tr>/table>/div>';
      document.write(itemHTML);
      itemNo++;
  }
        //添加菜單標(biāo)題和內(nèi)容,可任意多項(xiàng),注意格式:
  addItem('歡迎','BR>  WWW.CNBRUCE.COM');
  addItem('網(wǎng)頁(yè)專(zhuān)區(qū)','center>a  href="#">網(wǎng)頁(yè)工具/a>  BR>BR>a  href="#">技術(shù)平臺(tái)/a>  BR>BR>a  href="#">設(shè)計(jì)理念/a>  BR>BR>a  href="#">更多/a>/center>');
  addItem('美工教室','center>a  href="#">平面設(shè)計(jì)  /a>  BR>BR>a  href="#">三維空間/a>  BR>BR>a  href="#">設(shè)計(jì)基礎(chǔ)/a>  BR>BR>a  href="#">更多../a>/center>');
  addItem('Flash','center>a  href="#">基礎(chǔ)教程/a>  BR>BR>a  href="#">技巧運(yùn)用/a>  BR>BR>a  href="#">實(shí)例剖析/a>  BR>BR>a  href="#">更多../a>/center>');
  addItem('多媒體','center>a  href="#">DIRECTOR/a>  BR>BR>a  href="#">Authorware/a>  BR>BR>a  href="#">更多../a>/center>');
  addItem('精品賞析','center>a  href="#">設(shè)計(jì)精品/a>/center>');

  document.write('/span>')
  document.all.itemsLayer.style.height=itemNo*titleHeight+contentHeight;

  toItemIndex=itemNo-1;onItemIndex=itemNo-1;

  function  changeItem(clickItemIndex){
      toItemIndex=clickItemIndex;
      if(toItemIndex-onItemIndex>0)  moveUp();  else  moveDown();
      runtimes++;
      if(runtimes>=stepNo){
          onItemIndex=toItemIndex;
          runtimes=0;}
      else
          setTimeout("changeItem(toItemIndex)",10);
  }

  function  moveUp(){
      for(i=onItemIndex+1;i=toItemIndex;i++)
          eval('document.all.item'+i+'.style.top=parseInt(document.all.item'+i+'.style.top)-contentHeight/stepNo;');
  }

  function  moveDown(){
      for(i=onItemIndex;i>toItemIndex;i--)
          eval('document.all.item'+i+'.style.top=parseInt(document.all.item'+i+'.style.top)+contentHeight/stepNo;');
  }
  changeItem(0);
//-->
/script>
/body>

標(biāo)簽:蚌埠 衢州 棗莊 江蘇 萍鄉(xiāng) 廣元 大理 衡水

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP與數(shù)據(jù)庫(kù),有用的代碼(轉(zhuǎn)貼,摘貼)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢(xún)

    • 400-1100-266