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

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

熱門標(biāo)簽:虛擬電話外呼系統(tǒng) 成都ai外呼系統(tǒng)線路 沈陽三五防封電銷卡 鄢陵學(xué)校如何做地圖標(biāo)注 云南便宜外呼系統(tǒng)平臺 沈陽電話機器人公司 廣東語音外呼系統(tǒng)公司 長春公司外呼系統(tǒng)中心 鄭州智能外呼電銷機器人廠家
ASP與數(shù)據(jù)庫

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

 


q 文 章 點 評       3 篇


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



 

第三招:控制你的彈出窗口只彈出一次(如果每進一次,刷新一次就彈出你不覺得很煩和麻煩嗎?)有什么好的辦法嗎?
那是當(dāng)然的啊,我們現(xiàn)在只要使用cookie來控制就能實現(xiàn)這樣的要求了。
首先,你需把將如下代碼加入到頁面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()">替換頁面中原來的<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()
……             '將帖子入庫
----------------------------------------------------------

                    ASP項目中的公共翻頁模塊:

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

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

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

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

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

a href="%=fileName%>?PageNo=%=TotalPage%>">末頁/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=請輸入頁號,然后回車> 
%End If%>頁 
/td> 
/tr> 
/table> 
%End Sub%> 

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

調(diào)用方法: 
1、在程序開始或要使用翻頁的地方包含翻頁模塊文件; 
2、定義變量:RowCount,每頁顯示的記錄條數(shù) 
3、調(diào)用翻頁過程: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 '獲取的記錄集 

'公共翻頁模塊開始%> 
!--#include file=../Public/TurnPage.asp--> 

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

table width=100%> 
tr> 
td>新聞編號/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()
……             '將帖子入庫


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

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>
-------------------------------------------------------
我的下拉框中又兩個選項,當(dāng)選擇第一個時,出現(xiàn)一個用戶輸入頁面,但是有一部分input框是不要用戶填寫的。當(dāng)選擇第二項時,出現(xiàn)地頁面是全部都要填寫的。不知道該如何實現(xiàn)?
select onchange="text1.disabled=this.selectedIndex==0">
option>False/option>
option>True/option>
/select>
input type=text id=text1 disabled>
------------------------------------------------------------------>>>>>>>>>>>>>>
我的目的是:打開一個web頁(就稱為'原頁' 吧),點擊一個按鈕彈出一個小窗口(原頁不關(guān),小窗口最好可以拖動),在小窗口里提交一個表單到原頁。有什么方法可以實現(xiàn)?
給『原頁』一個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>

==============================================
沒有邊框的窗口::;;;;

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ù)組說明:此數(shù)組儲存菜單各部份顏色樣式,可以改變顏色值達到改變樣式的效果
//  值依次為:高亮背景色,  高亮邊框色,  菜單欄背景色,  子菜單背景色,  子菜單邊框色,  子菜單標(biāo)題色,  子菜單陰影色

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

//  菜單數(shù)組說明:此數(shù)組儲存各菜單數(shù)據(jù)
//  值依次為:
//  1.  主菜單名稱,  下拉菜單右延空白長度
//  2.  第1個子菜單名稱,  鏈接地址
//  3.  第2個子菜單名稱,  鏈接地址
//  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;                  //移動步數(shù),數(shù)值越大移動越慢

  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)容,可任意多項,注意格式:
  addItem('歡迎','BR>  WWW.CNBRUCE.COM');
  addItem('網(wǎng)頁專區(qū)','center>a  href="#">網(wǎng)頁工具/a>  BR>BR>a  href="#">技術(shù)平臺/a>  BR>BR>a  href="#">設(shè)計理念/a>  BR>BR>a  href="#">更多/a>/center>');
  addItem('美工教室','center>a  href="#">平面設(shè)計  /a>  BR>BR>a  href="#">三維空間/a>  BR>BR>a  href="#">設(shè)計基礎(chǔ)/a>  BR>BR>a  href="#">更多../a>/center>');
  addItem('Flash','center>a  href="#">基礎(chǔ)教程/a>  BR>BR>a  href="#">技巧運用/a>  BR>BR>a  href="#">實例剖析/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è)計精品/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)簽:孝感 朝陽 馬鞍山 四平 湖北 平頂山 遼陽 防城港

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP與數(shù)據(jù)庫,有用的代碼(轉(zhuǎn)貼,摘貼)》,本文關(guān)鍵詞  ASP,與,數(shù)據(jù)庫,有,用的,代碼,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP與數(shù)據(jù)庫,有用的代碼(轉(zhuǎn)貼,摘貼)》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP與數(shù)據(jù)庫,有用的代碼(轉(zhuǎn)貼,摘貼)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章