1)在该服务器机器上没有测试服务器运行

bywzy 发表于 程序设计 分类,
0

昨天在Dreamweaver中打开原来的程序后,在应用程序组里的表为空。
测试连接时,出现了以下错误:
Macromedia Dreamweaver
—————————
HTTP错误404 无法找到文件。该问题可能由以下一些原因造成:
1) 在该服务器机器上没有测试服务器运行。
2) 为该站点指定的测试服务器没有映射到http://localhost/_mmServerScripts/MMHTTPDB.aspURL。请确认URL前缀映射到了您站点的根上。


一开始,我以为是站点设置错误,可是改来改去。还是没有用

后来在网上发现了这段解释说明:[http://www.it365cn.com/show.asp?id=1401]
出现此问题的原因是站点的测试根目录使用了localhost,只要改为其他任何地方都行。但是要注意在Dreamweaver和IIS中使用相同的设置(此处假设为chinese),则Dreamweaver测试 服务器URL前缀使用http://localhost/chinese/。IIS设置的时候使用别名用刚才的chinese,其他均按照 平常的设置。此时,你会发现在Dreamweaver中可以使用F12预览网页。再使用自定义连接字符串就成功了 。

我按上边的方法改了。问题还是一样。

后来我将IIS中站的地址改为(All Unassigned)

再测试连接成功

可能是因为原来IIS中设定了固定的IP地址的原因吧。


如何让表单回车不提交 回车换行

bywzy 发表于 程序设计 分类,
0

上次帮财务部门写的程序,人家说要改。
输入时,希望回车后自动进入下一个输入框

法一:
ENTER键可以让光标移到下一个输入框    
  <input 。。。。。。。  onkeydown="if(event.keyCode==13)event.keyCode=9">  
    
到最后到达按钮焦点再回车就自动提交了

ASP入门教程 ASP应用开发基础 实例

bywzy 发表于 程序设计 分类,
0

<1>基本框架
<%
语句
……
%>
<2>定义变量dim语句
<%
dim a,b
a=10
b=”ok!”
%>
注意:定义的变量可以是数值型,也可以是字符或者其他类型的

<3>简单的控制流程语句
1. If 条件1 then
语句1
elseif 条件2 then
语句2
else
语句3
endif

2.while 条件
语句
wend

3.for count=1 to n step m
语句1
exit for
语句2
next

二.ASP数据库简单*作教程
<1>.数据库连接(用来单独编制连接文件conn.asp)
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("\bbs\db1\user.mdb")
%>
(用来连接bbs\db1\目录下的user.mdb数据库)

<2>显示数据库记录
原理:将数据库中的记录一一显示到客户端浏览器,依次读出数据库中的每一条记录
如果是从头到尾:用循环并判断指针是否到末 使用: not rs.eof
如果是从尾到头:用循环并判断指针是否到开始 使用:not rs.bof

<!–#include file=conn.asp–> (包含conn.asp用来打开bbs\db1\目录下的user.mdb数据库)
<%
set rs=server.CreateObject("adodb.recordset") (建立recordset对象)
sqlstr="select * from message" —->(message为数据库中的一个数据表,即你要显示的数据所存放的数据表)
rs.open sqlstr,conn,1,3 —->(表示打开数据库的方式)
rs.movefirst —->(将指针移到第一条记录)
while not rs.eof —->(判断指针是否到末尾)
response.write(rs("name")) —->(显示数据表message中的name字段)
rs.movenext —->(将指针移动到下一条记录)
wend —->(循环结束)
rs.close
conn.close 这几句是用来关闭数据库
set rs=nothing
set conn=nothing
%>
其中response对象是服务器向客户端浏览器发送的信息.

<3>增加数据库记录
增加数据库记录用到rs.addnew,rs.update两个函数
<!–#include file=conn.asp–> (包含conn.asp用来打开bbs\db1\目录下的user.mdb数据库)
<%
set rs=server.CreateObject("adodb.recordset") (建立recordset对象)
sqlstr="select * from message" —->(message为数据库中的一个数据表,即你要显示的数据所存放的数据表)
rs.open sqlstr,conn,1,3 —->(表示打开数据库的方式)
rs.addnew 新增加一条记录
rs("name")="xx" 将xx的值传给name字段
rs.update 刷新数据库
rs.close
conn.close 这几句是用来关闭数据库
set rs=nothing
set conn=nothing
%>

<4>删除一条记录
删除数据库记录主要用到rs.delete,rs.update
<!–#include file=conn.asp–> (包含conn.asp用来打开bbs\db1\目录下的user.mdb数据库)
<%
dim name
name="xx"
set rs=server.CreateObject("adodb.recordset") (建立recordset对象)
sqlstr="select * from message" —->(message为数据库中的一个数据表,即你要显示的数据所存放的数据表)
rs.open sqlstr,conn,1,3 —->(表示打开数据库的方式)
while not rs.eof
if rs.("name")=name then
rs.delete
rs.update 查询数据表中的name字段的值是否等于变量name的值"xx",如果符合就执行删除,
else 否则继续查询,直到指针到末尾为止
rs.movenext
emd if
wend
rs.close
conn.close 这几句是用来关闭数据库
set rs=nothing
set conn=nothing
%>

<5>关于数据库的查询
(a) 查询字段为字符型
<%
dim user,pass,qq,mail,message
user=request.Form("user")
pass=request.Form("pass")
qq=request.Form("qq")
mail=request.Form("mail")
message=request.Form("message")
if trim(user)&"x"="x" or trim(pass)&"x"="x" then (检测user值和pass值是否为空,可以检测到空格)
response.write("注册信息不能为空")
else
set rs=server.CreateObject("adodb.recordset")
sqlstr="select * from user where user=‘‘‘‘"&user&"‘‘‘‘" (查询user数据表中的user字段其中user字段为字符型)
rs.open sqlstr,conn,1,3
if rs.eof then
rs.addnew
rs("user")=user
rs("pass")=pass
rs("qq")=qq
rs("mail")=mail
rs("message")=message
rs.update
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write("注册成功")
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write("注册重名")
%>
(b)查询字段为数字型
<%
dim num
num=request.Form("num")
set rs=server.CreateObject("adodb.recordset")
sqlstr="select * from message where id="&num (查询message数据表中id字段的值是否与num相等,其中id为数字型)
rs.open sqlstr,conn,1,3
if not rs.eof then
rs.delete
rs.update
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write("删除成功")
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
response.write("删除失败")
%>

<6>几个简单的asp对象的讲解
response对象:服务器端向客户端发送的信息对象,包括直接发送信息给浏览器,重新定向URL,或设置cookie值
request对象:客户端向服务器提出的请求
session对象:作为一个全局变量,在整个站点都生效
server对象:提供对服务器上方法和属性的访问
(a) response对象的一般使用方法
比如:
<%
resposne.write("hello, welcome to asp!")
%>
在客户端浏览器就会看到 hello, welcome to asp! 这一段文字
<%
response.Redirect("www.sohu.com")
%>
如果执行这一段,则浏览器就会自动连接到 “搜狐” 的网址
关于response对象的用法还有很多,大家可以研究研究
request对象的一般使用方法
比如客户端向服务器提出的请求就是通过request对象来传递的
列如 :你在申请邮箱的所填写的个人信息就是通过该对象来将
你所填写的信息传递给服务器的
比如:这是一段表单的代码,这是提供给客户填写信息的,填写完了按
“提交”传递给request.asp文件处理后再存入服务器数据库
<form name="form1" method="post" action="request.asp">
<p>
<input type="text" name="user">
</p>
<p>
<input type="text" name="pass">
</p>
<p>
<input type="submit" name="Submit" value="提交">
</p>
</form>
那么request.asp该如何将其中的信息读入,在写入数据库,在这里就要用到
request对象了,下面我们就来分析request.asp的写法
<%
dim name,password (定义user和password两个变量)
name=request.form(“user”) (将表单中的user信息传给变量name)
password=request.form(“pass”) (将表单中的pass信息传给变量password)
%>

通过以上的几句代码我们就将表单中的数据读进来了,接下来我们要做的就是将
信息写入数据库了,写入数据库的方法上面都介绍了,这里
就不一一复述了。

用JS自动生成等比例缩略图

bywzy 发表于 程序设计 分类,
0

第一种方法(加载后,等比较缩小 缺点是图片大或多的时候,打开速度慢):
<img src=""   border=0 id="img1" onload="Wa_SetImgAutoSize();">

function Wa_SetImgAutoSize()
{
var img=document.all.img1;//获取图片
var MaxWidth=200;//设置图片宽度界限@@@@@@@@@@@
var MaxHeight=100;//设置图片高度界限@@@@@@@@@@@@@@@
var HeightWidth=img.offsetHeight/img.offsetWidth;//设置高宽比
var WidthHeight=img.offsetWidth/img.offsetHeight;//设置宽高比
if(img.readyState!="complete")return false;//确保图片完全加载
if(img.offsetWidth>MaxWidth){
  img.width=MaxWidth;
  img.height=MaxWidth*HeightWidth;
}
if(img.offsetHeight>MaxHeight){
  img.height=MaxHeight;
  img.width=MaxHeight*WidthHeight;
}
}
第二种:(正在测试中。。。)

网页特效代码 可别小看这些代码

bywzy 发表于 程序设计 分类,
0

控制横向和纵向滚动条的显隐?
<body style="overflow-y:hidden"> 去掉x轴
<body style="overflow-x:hidden"> 去掉y轴
<body scroll="no">不显

——————————————————————————–
表格变色
<TD onmouseover="this.style.backgroundColor=‘#FFFFFF‘"  
onmouseout="this.style.backgroundColor=‘‘"
style="CURSOR: hand">  
——————————————————————————–
禁止复制,鼠标拖动选取
<body ondragstart=window.event.returnValue=false oncontextmenu=window.event.returnValue=false onselectstart=event.returnValue=false>  
——————————————————————————–
普通iframe页面
<iframe name="name" src="main.htm" width="450" height="287" scrolling="Auto" frameborder="0"></iframe>

——————————————————————————–
iframe自适应高度
<iframe name="pindex" src="index.asp" frameborder=false scrolling="auto" width="100%" height="100%" frameborder=no onload="document.all[‘pindex‘].style.height=pindex.document.body.scrollHeight" ></iframe>  
——————————————————————————–
IE地址栏前换成自己的图标&可以在收藏夹中显示出你的图标
<link rel="Shortcut Icon" href="favicon.ico">
<link rel="Bookmark" href="favicon.ico">  
——————————————————————————–
字号缩放
越来越多的人长时间的泡网,眼镜的普及率也越来越高,让文字大点,让更多的用户看的更清楚。
<script type="text/javascript">
function doZoom(size)
{document.getElementById(‘zoom‘).style.fontSize=size+‘px‘;}
</script>
<span id="zoom">需要指定大小的文字</span>
<a href="javascript:doZoom(16)">大</a> <a href="javascript:doZoom(14)">中</a> <a href="javascript:doZoom(12)">小</a>  
——————————————————————————–
select挡住div的解决方法  
在div里加入下面的代码,根据需要调整就可以了。
<iframe src="javascript:false" scrolling="no" frameborder="0" style="z-index:-1;position:absolute; top:5px; left:2px;width:168;height:100px;">
</iframe>

——————————————————————————–
iframe(嵌入式帧)自适应高度
填写的嵌入地址一定要和本页面在同一个站点上,否则会提示“拒绝访问!”。对跨域引用有权限问题,请查阅其他资料。
<iframe name="guestbook" src="gbook/index.asp" scrolling=no width="100%" height="100%" frameborder=no onload="document.all[‘guestbook‘].style.height=guestbook.document.body.scrollHeight"></iframe>  
——————————————————————————–
跳转菜单新窗口
<select name="select" onchange="window.open(this.options[this.selectedIndex].value)">
<option value="http://www.ycsznet.com"> Internet Explorer</option>
<option value="http://www.sinicpart.com"> Microsoft Home</option>
<option value="http://msdn.microsoft.com"> Developer Network</option>
</select>  
——————————————————————————–
flash透明选项
<param name="wmode" value="transparent">  
——————————————————————————–

添加到收藏夹和设为首页
<a href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.ycsznet.com');">设为首页</a>

<a href="javascript:window.external.AddFavorite('http://www.ycsznet.com','人生译站')">收藏本站</a>

——————————————————————————–
记录并显示网页的最后修改时间
<script language=JavaScript>  
document.write("最后更新时间: " + document.lastModified + ""  
</script>  
——————————————————————————–
节日倒计时
<Script Language="JavaScript">  
   var timedate= new Date("October 1,2002";  
   var times= "国庆节";  
   var now = new Date();  
   var date = timedate.getTime() – now.getTime();  
   var time = Math.floor(date / (1000 * 60 * 60 * 24));  
   if (time >= 0)  
   document.write( "现在离"+times+"还有: "+time +"天"
</Script>  
——————————————————————————–
加在HEAD里  
禁止缓存
<meta http-equiv="Expires" CONTENT="0">  
<meta http-equiv="Cache-Control" CONTENT="no-cache">  
<meta http-equiv="Pragma" CONTENT="no-cache">  

——————————————————————————–
让IFRAME框架内的文档的背景透明
<iframe src="about:<body style=‘background:transparent‘>" allowtransparency></iframe>  
——————————————————————————–
打开窗口即最大化
<script language="JavaScript">  
<!– Begin  
self.moveTo(0,0)  
self.resizeTo(screen.availWidth,screen.availHeight)  
// End –>  
</script>  
——————————————————————————–
加入背景音乐
<bgsound src="mid/windblue[1].mid" loop="-1"> 只适用于IE
<embed src="music.mid" autostart="true" loop="true" hidden="true"> 对Netscape ,IE 都适用  
——————————————————————————–
滚动
<marquee direction=up height=146 onmouseout=start() onmouseover=stop() scrollAmount=2>滚动信息
</marquee>  
——————————————————————————–
防止点击空链接时,页面往往重置到页首端
代码“javascript:void(null)”代替原来的“#”标记  
——————————————————————————–

文字或图片弹出指

HTML文件 文件包含 include文件

bywzy 发表于 程序设计 分类,
0

在论坛中常常有网友问到,可以在一个html的文件当中读取另一个html文件的内容吗?答案是确定的,而且方法不只一种,在以前我只会使用iframe来引用,后来发现了另外的几种方法,那今天就总结这几种方法让大家参考一下,本人觉得第三种方式较好!
        1.IFrame引入,看看下面的代码
        <IFRAME NAME="content_frame" width=100% height=30 marginwidth=0 marginheight=0 SRC="import.htm" ></IFRAME>

        你会看到一个外部引入的文件,但会发现有一个类似外框的东西将其包围,可使用:

         <iframe name="content_frame" marginwidth=0 marginheight=0 width=100% height=30 src="import.htm" frameborder=0></iframe>


        但你会发现还会有点问题,就是背景色不同,你只要在引入的文件import.htm中使用相同的背景色也可以,但如果你使用的是IE5.5的话,可以看看这篇关于透明色的文章 如果想引入的文件过长时不出现滚动条的话在import.htm中的body中加入scroll=no


        2.<object>方式

        <object style="border:0px" type="text/x-scriptlet" data="import.htm" width=100% height=30></object>


        3.Behavior的download方式

        <span id=showImport></span>
        <IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
        <script>
        function onDownloadDone(downDate){
        showImport.innerHTML=downDate
        }
        oDownload.startDownload('import.htm',onDownloadDone)
        </script>

40个网页设计小技巧

bywzy 发表于 程序设计 分类,
0

40个网页设计小技巧
1.如何控制横向和纵向滚动条的显隐?
<body style="overflow-y:hidden"> 去掉x轴滚动条
<body style="overflow-x:hidden"> 去掉y轴滚动条
<body scroll="no">不显

2.表格变色
<TD onmouseover="this.style.backgroundColor='#FFFFFF'"
onmouseout="this.style.backgroundColor=''" style="CURSOR: hand">

3.禁止复制,鼠标拖动选取
<body ondragstart=window.event.returnValue=false oncontextmenu=window.event.returnValue=false
onselectstart=event.returnValue=false>

4.iframe的使用
<iframe  src="a.htm" width="50" height="50"  frameborder="0"></iframe>

5.在收藏夹及IE地址栏中显示出你的图标
<link rel="Shortcut Icon" href="favicon.ico">
<link rel="Bookmark" href="favicon.ico">

6.字号缩放
越来越多的人长时间的泡网,眼镜的普及率也越来越高,让文字大点,让更多的用户看的更清楚。
<script type="text/javascript">
function doZoom(size)
{document.getElementById('zoom').style.fontSize=size+'px';}
</script>
<span id="zoom">需要指定大小的文字</span>
<a href="javascript:doZoom(16)">大</a> <a href="javascript:doZoom(14)">中</a> <a href="javascript:doZoom(12)">小</a>

7.select挡住div的解决方法
在div里加入下面的代码,根据需要调整就可以了。
<iframe src="javascript:false" scrolling="no" frameborder="0" style="z-index:-1;position:absolute; top:5px; left:2px;width:168;height:100px;">
</iframe>

8.跳转菜单新窗口
<select name="select" onchange="window.open(this.options[this.selectedIndex].value)">
<option value="http://www.lihao.name"> lihao</option>
<option value="http://www.nai8.com"> nai8</option>
<option value="http://www.akbk.net"> akbk</option>
</select>

9.flash透明选项
<param name="wmode" value="transparent">

10.显示网页的最后更新时间
<script language=JavaScript>
document.write("最后更新时间: " + document.lastModified + "")
</script>

11.添加到收藏夹和设为首页
<a href=# onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.lihao.name/');">设为首页</a>

<a href="javascript:window.external.AddFavorite('http://www.lihao.name/','李好博客)">收藏本站</a>

图片设置方法:
<IMG SRC="lihao.gif" BORDER="0" ALT="设置为首页" onclick="this.style.behavior='url(#default#homepage)';this.sethomepage('http://www.lihao.name');return false;" style="cursor:hand">

<IMG SRC="bb.gif" BORDER="0" ALT="收藏此页面" onclick="window.external.addFavorite('http://www.lihao.name','李好博客')" style="cursor:hand">



12.加入背景音乐
<bgsound src="mid/windblue[1].mid" loop="-1"> 只适用于IE
<embed src="music.mid" autostart="true" loop="true" hidden="true"> 对Netscape ,IE 都适用

13.滚动
<marquee direction=up height=146 onmouseout=start() onmouseover=stop() scrollAmount=2>滚动信息</marquee>

14.跳转页面代码
<meta http-equiv="refresh" content="5;url=http://www.lihao.name">

15. flash按钮加链接
on (press) {
getURL("http://www.lihao.name","_blank");
}  

16.文字或图片弹出指定大小的窗口
在body中加入
<script language="JavaScript" type="text/JavaScript">
function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}
</script>
弹出代码
<a href="#" target="_self" onClick="MM_openBrWindow('windows01.htm','','width=550,height=380')" width="550" height="380" border="0">图片或文字</a>

17. 细分隔线
<hr noshade size=0 color=#C0C0C0>

18.网页中的自动换行
<td style="word-break:break-all">
完整的是:
style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word"

19. 消除ie6自动出现的图像工具栏,设置 GALLERYIMG属性为false或no .
<IMG SRC="mypicture.jpg" HEIGHT="100px" WIDTH="100px" GALLERYIMG="no">

20. 不能点右键,不用CTRL+A,不能复制作!
<body oncontextmenu="window.event.returnValue=false"
onkeypress="window.event.returnValue=false"
onkeydown="window.event.returnValue=false"
onkeyup="window.event.returnValue=false"
ondragstart="window.event.returnValue=false"
onselectstart="event.returnValue=false">
</body>

21.IE浏览器支持一个 Body 属性 bgproperties,它可以让背景不滚动:
<Body Background="图片文件" bgproperties="fixed">

22.随机变换背景图象(一个可以刷新心情的特效)
<Script Language="JavaScript">
   image = new Array(4); //定义image为图片数量的数组
   image [0] = 'tu0.gif' //背景图象的路径
   image [1] = 'tu1.gif'
   image [2] = 'tu2.gif'
   image [3] = 'tu3.gif'
   image [4] = 'tu4.gif'
   number = Math.floor(Math.random() * image.length);
   document.write("<BODY BACKGROUND="+image[number]+">");
</Script>

23.flash载入影片
on (release)
{
loadMovie("1-01.swf", "_root.loaderclip");
}

24. 图片表单按钮
<form id="form1" name="form1" method="post" action="">
<img src="login.gif" width="62" height="22" onclick="document.form1.submit()" />
</form>

25.左右阴影背景的CSS定义方法body {
text-align:center;
background-repeat: repeat-y;
background-position: center;
background-image: url(../images/bg.jpg);
}

26.划过链接 手型鼠标
style="cursor:hand"

27.关闭窗口的脚本
<a href=javascript:close()>[关闭窗口]</a>

28. 如果文字过长,则将过长的部分变成省略号显示
<DIV STYLE="width: 120px; height: 50px; border: 1px solid blue;overflow: hidden; text-overflow:ellipsis">
<NOBR>就是比如有一行文字,很长,表格内一行显示不下.</NOBR>
</DIV>

29. 进入主页后自动最大化
<script>
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
</script>

30. 凹

日期选择JS 日期选择程序 代码

bywzy 发表于 程序设计 分类,
0

JavaScript程序脚本和调用实例如下

HTML代码


[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

用CSS改变鼠标样式 CSS代码 CSS脚本

bywzy 发表于 程序设计 分类,
0

  auto 自动改变样式  
  crosshair 精确定位"+" 用鼠标指着我察看效果
  default 默认指针 用鼠标指着我察看效果
  hand 手形 用鼠标指着我察看效果
  move 移动 用鼠标指着我察看效果
  e-resize 箭头朝右方 用鼠标指着我察看效果
  ne-resize 箭头朝右上方 用鼠标指着我察看效果
  nw-resize 箭头朝左上方 用鼠标指着我察看效果
  n-resize 箭头朝上方 用鼠标指着我察看效果
  se-resize 箭头朝右下方 用鼠标指着我察看效果
  sw-resize 箭头朝左下方 用鼠标指着我察看效果
  s-resize 箭头朝下方 用鼠标指着我察看效果
  w-resize 箭头朝左方 用鼠标指着我察看效果
  text 文本"I"形 用鼠标指着我察看效果
  wait 等待 用鼠标指着我察看效果
  help 帮助 用鼠标指着我察看效果
先将以下代码复制到<head></head>之间:
<style type="text/css">
<–
a{font-style:normal;text-decoration:none;font-size:9pt;color:#0000cc}
a:hover {font-style:normal;text-decoration:none;font-size:9pt;color:#0000cc;background-color:#AFE0FE}
a:active {font-style:normal;text-decoration:none;font-size:9pt;color:#0000cc;background-color:#8080C0}
–>
BODY {
    FONT-FAMILY: 宋体; FONT-SIZE: 9pt
}
TABLE {
    FONT-FAMILY: 宋体; FONT-SIZE: 9pt
}

}
</style>


再将以下代码复制到<body></body>之间:

<div style="font-size:24pt;color:green;">
  <table width="647" border="0">
    <tr>
      <td width="157" height="26"> </td>
      <td colspan="3" height="26">
        <div align="center"><font size="4"><b><font color="#660066">用CSS改变鼠标样式</font></b></font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#990000">关键字:</font></td>
      <td width="156"><font color="#990000">解释:</font></td>
      <td width="192"><font color="#990000">样式:</font></td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">auto</font></td>
      <td width="156"><font color="#660066">自动改变样式</font></td>
      <td width="192">
        <div align="center"></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">crosshair</font></td>
      <td width="156"><font color="#660066">精确定位"+"</font></td>
      <td width="192">
        <div align="center" style="cursor:crosshair"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">default</font></td>
      <td width="156"><font color="#660066">默认指针</font></td>
      <td width="192">
        <div align="center" style="cursor:default"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">hand</font></td>
      <td width="156"><font color="#660066">手形</font></td>
      <td width="192">
        <div align="center" style="cursor:hand"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">move</font></td>
      <td width="156"><font color="#660066">移动</font></td>
      <td width="192">
        <div align="center" style="cursor:move"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">e-resize</font></td>
      <td width="156"><font color="#660066">箭头朝右方</font></td>
      <td width="192">
        <div align="center" style="cursor:e-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">ne-resize</font></td>
      <td width="156"><font color="#660066">箭头朝右上方</font></td>
      <td width="192">
        <div align="center
" style="cursor:ne-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">nw-resize</font></td>
      <td width="156"><font color="#660066">箭头朝左上方</font></td>
      <td width="192">
        <div align="center" style="cursor:nw-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">n-resize</font></td>
      <td width="156"><font color="#660066">箭头朝上方</font></td>
      <td width="192">
        <div align="center" style="cursor:n-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">se-resize</font></td>
      <td width="156"><font color="#660066">箭头朝右下方</font></td>
      <td width="192">
        <div align="center" style="cursor:se-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">sw-resize</font></td>
      <td width="156"><font color="#660066">箭头朝左下方</font></td>
      <td width="192">
        <div align="center" style="cursor:sw-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">s-resize</font></td>
      <td width="156"><font color="#660066">箭头朝下方</font></td>
      <td width="192">
        <div align="center" style="cursor:s-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">w-resize</font></td>
      <td width="156"><font color="#660066">箭头朝左方</font></td>
      <td width="192">
        <div align="center" style="cursor:w-resize"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">text</font></td>
      <td width="156"><font color="#660066">文本"I"形</font></td>
      <td width="192">
        <div align="center" style="cursor:text"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">wait</font></td>
      <td width="156"><font color="#660066">等待</font></td>
      <td width="192">
        <div align="center" style="cursor:wait"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157"> </td>
      <td width="137"><font color="#330066">help</font></td>
      <td width="156"><font color="#660066">帮助</font></td>
      <td width="192">
        <div align="center" style="cursor:help"><font color="#006666">用鼠标指着我察看效果</font></div>
      </td>
    </tr>
    <tr>
      <td width="157" height="23"> </td>
      <td width="485" colspan="3" height="23">
        <div align="left"><font color="#330066">使用方法:在需要改变鼠标样式的地方方插入:</font>style="cursor:<font color="#990000">关键字</font>"</div>
      </td>

XP风格的下拉菜单–网页菜单

bywzy 发表于 程序设计 分类,
0

偶然在网上看到

以下是本下拉菜单的源代码:

<script>
var menuwidth=117;
var menutop=20;
var menuspac=3;
var menuleft=10;
var menutitlewidth=80;
var menubackground='eaeaea';
var menuborder3='08246b';
var menuborder1='000000';
var menuborder2='646464';
var menuselectcolor='AEACD1';

var menu=new Array('盈嘉简介','项目介绍','技术展示','行业动态','盈嘉新闻','合作加盟','招贤纳士');

var menudata=new Array();
var menulist=new Array();

menulist[0]=new Array('dl.gif','公司','aaa();','dl.gif','公司','bb.htm',0,'<hr>',0,'dl.gif','公司','a.htm');
menulist[1]=new Array('dl.gif','剪切(I)','a.htm',0,'复制(C)','a.htm','dl.gif','粘贴(P)','a.htm','dl.gif','删除(L)','a.htm',0,'<hr>',0,'dl.gif','全选(A)','a.htm',0,'<hr>',0,'dl.gif','查找(F)','a.htm','dl.gif','编辑(E)','a.htm');
menulist[2]=new Array('dl.gif','分割符(B)','a.htm',0,'表格(A)',0,0,'图片(P)',1,'dl.gif','文本框(X)',2,0,'<hr>',0,'dl.gif','文件(L)','a.htm','dl.gif','对象(O)','aa.htm','dl.gif','书签(K)','a.htm','dl.gif','超级链接(I)','a.htm',0,'<hr>',0,'dl.gif','数字','a.htm','dl.gif','索引目录','a.htm',0,'<hr>',0,'dl.gif','符号','a.htm');
menulist[3]=new Array('dl.gif','公司','aaa();','dl.gif','公司','bb.htm',0,'<hr>',0,'dl.gif','公司','a.htm');
menulist[4]=new Array('dl.gif','公司','aaa();','dl.gif','公司','bb.htm',0,'<hr>',0,'dl.gif','公司','a.htm');
menulist[5]=new Array('dl.gif','公司','aaa();','dl.gif','公司','bb.htm',0,'<hr>',0,'dl.gif','公司','a.htm');
menulist[6]=new Array('dl.gif','公司','aaa();','dl.gif','公司','bb.htm',0,'<hr>',0,'dl.gif','公司','a.htm');

var menulist1=new Array();
menulist1[0]=new Array('dl.gif','公司11111',0,'dl.gif','公司',1,'dl.gif','公司',2);
menulist1[1]=new Array('dl.gif','公司','a.htm','dl.gif','公司','a.htm',0,'<hr>',0,'dl.gif','公司','a.htm','dl.gif','公司','a.htm',0,'<hr>',0,'dl.gif','公司','a.htm');
menulist1[2]=new Array('dl.gif','公司','a.htm','dl.gif','公司','a.htm');

var menulist2=new Array();
menulist2[0]=new Array('dl.gif','公司22222','a.htm','dl.gif','公司','a.htm','dl.gif','公司','a.htm','dl.gif','公司','a.htm');
menulist2[1]=new Array('dl.gif','公司','a.htm','dl.gif','公司','a.htm','dl.gif','公司','a.htm','dl.gif','公司','a.htm');
menulist2[2]=new Array('dl.gif','公司','a.htm','dl.gif','公司','a.htm','dl.gif','公司','a.htm','dl.gif','公司','a.htm');


//menuwidth,menutop,menuleft,menutitle,menutitlewidth,menunum,menubackground,menuborder3,menuselectcolor
//pic,title,url

var menuhtml=
'<style>' +
'td {font:12.6px "宋体";}' +
'.menua{height:15px; cursor:hand; border:1 double #' + menuborder1 + ';}' +
'.menub{height:15px; cursor:hand; border:1 double #' + menuborder1 + '; background:' + menuselectcolor + ';}' +
'.menuimg{background:' + menubackground + '}' +
'</style>' +
'<table width="' + (menutitlewidth+menuspac*2+1)*menu.length + '" cellspacing="' + menuspac + '" cellpadding="0" style="position:absolute; top:' +menutop + 'px; left:' + menuleft + 'px; border:none;" onSelectStart="event.returnValue=false;" onConTextMenu="event.returnValue=false">' +
' <tr>';
for(i=0;i<menu.length;i++) {
var menuarray=menu[i].split('(');
if (menuarray[1]!=null) {
menuarray[1]=menuarray[1].split(')');
menutext=menuarray[0] + '(<u>' + menuarray[1][0] + '</u>)';
} else menutext=menuarray[0];
menuhtml+=
' <td class=menua onMouseOut="this.className=\'menua\';" onMouseOver="this.className=\'menub\';" onclick="menushow(' + menuwidth + ',' + (menutop+menuspac) + ',' + (menuleft+((menutitlewidth+6)*i)+menuspac) + ',\'' + menutext + '\',this.offsetWidth,' + i + ',\'' + menubackground + '\',\'' + menuborder2 + '\',\'' + menuselectcolor + '\');" style="width:' + menutitlewidth + 'pt; cursor:hand; text-align:center">' + menutext + '</td>';
}
menuhtml+=
' </tr>' +
'</table>' +
'<div id="menu" style="position:absolute; visibility:hidden; z-index:1000"></div>' +
'<div id="menu1" style="position:absolute; visibility:hidden; z-index:1001"></div>' +
'<div id="menu2" style="position:absolute; visibility:hidden; z-index:1002"></div>' +
'<div id="menu3" style="position:absolute; visibility:hidden; z-index:1003"></div>' +
'<div id="menu4" style="position:absolute; visibility:hidden; z-index:1004"></div>' +
'<div id="menu5" style="position:absolute; visibility:hidden; z-index:1005"></div>' +
'<div id="menu6" style="position:absolute; visibility:hidden; z-index:1006"></div>';
document.write(menuhtml);


function menushow(menuwidth,menutop,menuleft,menutitle,menutitlewidth,menunum,menubackground,menuborder2,menuselectcolor){
if (document.all.menu.style.visibility=='hidden' && menutitle!=null) {
document.all.menu.innerHTML=
'<table width="' + menuwidth + '" border="1" cellspacing="0" cellpadding="0" style="border:none;" onSelectStart="event.returnValue=false;" onConTextMenu="event.returnValue=false">\n' +
' <tr onclick="menushow();">\n' +
' <td width="' + (menutitlewidth-2) + '" style="height:18px; border-left:1 double #' + menuborder2 + '; border-right:1 double #' + menuborder2 + '; border-top:1 double #' + menuborder2 + '; border-bottom:none; background:' + menubackground + '; text-align:center; cursor:hand">' + menutitle + '</td>\n' +

' <td width="' + (menuwidth-menutitlewidth+2) + '" style="border-left:none; border-right:none; border-top:none; border-bottom:1 double #' + menuborder2 + '"> </td>\n' +
' </tr>\n' +
' <tr>\n' +
' <td colspan="2" style="height:' + Math.round(menulist[menunum].length/3*18) + 'px; border:none">\n' +
'<iframe name=menutools frameborder="0" width="100%" height="100%" scrolling="no"></iframe>\n' +
' </td>\n' +
' </tr>\n' +
'</table>\n';

menushowlist(menuwidth,menutop,menuleft,menunum,menubackground,menuborder3,menuselectcolor);

document.all.menu.style.width=menuwidth;
document.all.menu.style.pixelTop=menutop;
document.all.menu.style.pixelLeft=menuleft;
document.all.menu.style.visibility='visible';

}else{

if (document.all["menu1"].style.visibility=='hidden') document.all.menu.style.visibility='hidden';
for(i=1;i<menulist.length;i++) document.all["menu"+i].style.visibility='hidden';

}
}
function menushowlist(menuwidth,menutop,menuleft,menunum,menubackground,menuborder3,menuselectcolor){

var menulisthtml=
'<style>\n' +
'td {font:12.6px "宋体";}\n' +
'.menua{word-wrap:break-word; cursor:hand; border:none; height:15px}\n' +
'.menub{word-wrap:break-word; cursor:hand; border:1 double #' + menuborder3 + '; height:15px; background:' + menuselectcolor + '; filter:alpha(opacity=50);}\n' +
'.menuc{word-wrap:break-word; cursor:hand; border:1 double #' + menuborder3 + '; height:15px; background:' + menuselectcolor + '; filter:alpha(opacity=80);}\n' +
'.menuimg{height:15px; background:' + menubackground + ';}\n' +
'</style>\n' +
'<body bgcolor=white text=black id=all  topmargin="0" leftmargin="0" onSelectStart="event.returnValue=false;" onConTextMenu="event.returnValue=false">\n' +
'<table width="' + menuwidth + '" height="100%" border="0" cellspacing="0" cellpadding="0" style="position:absolute; z-index:1;">\n';
for(i=0;i<menulist[menunum].length/3;i++) {
if (menulist[menunum][i*3]!=0) menuimg='<img src="' + menulist[menunum][i*3] + '" width="12" height="12">'; else menuimg='';
if (menulist[menunum][i*3+2]>=0) menudown='<font style="font:10px webdings">4</font>'; else menudown='';
if (menulist[menunum][i*3+1]=='<hr>') {menudown='<font style="font:10px">————————</font>';menuimg='';}
menulisthtml+=
' <tr><td class="menuimg" align="middle">' + menuimg + '</td><td width="' + (menuwidth-24) + '" align=right>' + menudown + ' </td></tr>\n';
}
menulisthtml+=
' </table>\n' +
' <table width="' + menuwidth + '" height="100%" border="0" cellpadding="0" style="border-left:1 solid #' + menuborder2 + '; border-right:1 solid #' + menuborder2 + '; border-top:none; border-bottom:1 solid #' + menuborder2 + '; table-layout:fixed; position:absolute; z-index:2">\n';
menulistleft=menuleft*1+menuwidth+2;
for(i=0;i<menulist[menunum].length/3;i++) {
menulisttop=menutop*1+(i+1)*17;
if (menulist[menunum][i*3+1]=='<hr>') menulisthtml+='<tr><td class="menua" style="cursor:default"> </td></tr>';
else {
var menuarray=menulist[menunum][i*3+1].split('(');
if (menuarray[0].length>menuwidth/10-3)
menutext=' title="' + menuarray[0] + '">  ' + menuarray[0].substring(0,menuwidth/10)+"…";
else
menutext='>  ' + menuarray[0];
if (menuarray[1]!=null) {
menuarray[1]=menuarray[1].split(')');
menutext+='(<u>' + menuarray[1][0] + '</u>)';
}
menulisthtml+=
' <tr><td class="menua" onMouseOut="this.className=\'menua\';" onMouseOver="this.className=\'menub\';" onMouseDown="this.className=\'menuc\';" onclick="parent.';
if (menulist[menunum][i*3+2]>=0) {
menulisthtml+='menushowlisttable(1,' + menuwidth + ',\'' + menulisttop + '\',\'' + menulistleft + '\',' + menulist[menunum][i*3+2] + ',\'' + menubackground + '\',\'' + menuborder3 + '\',\'' + menuselectcolor + '\');';
}
else {
var menuclick=menulist[menunum][i*3+2].split('.');
if (menuclick[1]=='htm') menulisthtml+='openwin(\'' + menulist[menunum][i*3+2] + '\');';
else menulisthtml+=menulist[menunum][i*3+2];
}
menulisthtml+=
'" valign="bottom"' + menutext + '</td></tr>\n';
}
}
menulisthtml+=
' </table>';
menutools.document.write(menulisthtml);
}

function menushowlisttable(menunum,menuwidth,menutop,menuleft,menudatanum,menubackground,menuborder3,menuselectcolor){
if (menunum==1){menudata=menulist1[menudatanum]}
else if (menunum==2){menudata=menulist2[menudatanum]}
else return;
if (document.all["menu"+menunum].style.visibility=='hidden') {
document.all["menu"+menunum].innerHTML=
'<table width="' + menuwidth + '" border="1" cellspacing="0" cellpadding="0" style="border:none" onSelectStart="event.returnValue=false;" onConTextMenu="event.returnValue=false">\n' +
' <tr>\n' +
' <td colspan="2" style="height:' + Math.round(menudata.length/3*18) + 'px; border:none">\n' +
'<iframe name="menutools'+ menunum +'" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>\n' +
' </td>\n' +
' </tr>\n' +
'</table>\n';

menushowlistselect(menunum,menuwidth,menutop,menuleft,menudata,menubackground,menuborder3,menuselectcolor);

document.all["menu"+menunum].style.width=menuwidth;
document.all["menu"+menunum].style.pixelTop=menutop;
document.all["menu"+menunum].style.pixelLeft=menuleft;
document.all["menu"+menunum].style.visibility='visible';

}else{
if (document.all["menu"+menunum].style.visibility=='hidden') document.all["menu"+menunum].style.visibility='hidden';
for(i=menunum;i<menulist.length;i++) document.all["menu"+i].style.visibility='hidden';
}
}

function menushowlistselect(menunum,menuwidth,menutop,menuleft,menudata,menubackground,menuborder3,menuselectcolor){

var menulisthtml=
'<style>\n' +
'td {font:12.6px "宋体";}\n' +
'.menua{word-wrap:break-word; cursor:hand; border:none; height:15px}\n' +
'.menub{word-wrap:break-word; cursor:hand; border:1 double #' + menuborder3 + '; height:13px; background:' + menuselectcolor + '; filter:alpha(opacity=50);}\n' +
'.menuc{word-wrap:break-word; cursor:hand; border:1 double #' + menuborder3 + '; height:13px;
background:' + menuselectcolor + '; filter:alpha(opacity=80);}\n' +
'.menuimg{height:17px; background:' + menubackground + ';}\n' +
'</style>\n' +
'<body bgcolor=white text=black id=all  topmargin="0" leftmargin="0" onSelectStart="event.returnValue=false;" onConTextMenu="event.returnValue=false">\n' +
'<table width="' + menuwidth + '" height="100%" border="0" cellspacing="0" cellpadding="0" style="border-left:1 solid #' + menuborder2 + '; border-right:1 solid #' + menuborder2 + '; border-top:1 solid #' + menuborder2 + '; border-bottom:1 solid #' + menuborder2 + '; position:absolute; z-index:1;">\n';

for(i=0;i<menudata.length/3;i++) {
if (menudata[i*3]!=0) menuimg='<img src="' + menudata[i*3] + '" width="12" height="12">'; else menuimg='';
if (menudata[i*3+2]>=0) menudown='<font style="font:10px webdings">4</font>'; else menudown='';
if (menudata[i*3+1]=='<hr>') {menudown='<font style="font:10px">————————</font>';menuimg='';}
menulisthtml+=
' <tr><td class="menuimg" align="middle">' + menuimg + '</td><td width="' + (menuwidth-24) + '" align=right>' + menudown + ' </td></tr>\n';
}
menulisthtml+=
' </table>\n' +
' <table width="' + menuwidth + '" height="100%" border="0" cellpadding="0" style="border:none; table-layout:fixed; position:absolute; z-index:2">\n';
menulistleft=menuleft*1+menuwidth+2;
for(i=0;i<menudata.length/3;i++) {
menulisttop=menutop*1+i*17;
if (menudata[i*3+1]=='<hr>') menulisthtml+='<tr><td class="menua" style="cursor:default"> </td></tr>';
else {
var menuarray=menudata[i*3+1].split('(');
if (menuarray[0].length>menuwidth/10-3)
menutext=' title="' + menuarray[0] + '">  ' + menuarray[0].substring(0,menuwidth/10)+"…";
else
menutext='>  ' + menuarray[0];
if (menuarray[1]!=null) {
menuarray[1]=menuarray[1].split(')');
menutext+='(<u>' + menuarray[1][0] + '</u>)';
}
menulisthtml+=
' <tr><td class="menua" onMouseOut="this.className=\'menua\';" onMouseOver="this.className=\'menub\';" onMouseDown="this.className=\'menuc\';" onclick="parent.';
if (menudata[i*3+2]>=0)
menulisthtml+='menushowlisttable(2,' + menuwidth + ',\'' + menulisttop + '\',\'' + menulistleft + '\',' + menudata[i*3+2] + ',\'' + menubackground + '\',\'' + menuborder3 + '\',\'' + menuselectcolor + '\');';
else {
var menuclick=menudata[i*3+2].split('.');
if (menuclick[1]=='htm') menulisthtml+='openwin(\'' + menudata[i*3+2] + '\');';
else menulisthtml+=menudata[i*3+2];
}
menulisthtml+=
'" valign="bottom"' + menutext + '</td></tr>\n';
}
}
menulisthtml+=
' </table>';
parent.frames["menutools"+menunum].document.write(menulisthtml);

}


function openwin(a){
Win=open(a,'_top');
}

function aaa(){
}
</script>

将以下代码保存为htm格式的文件,即可在浏览器(IE)中看到漂亮的菜单了!