浮動(dòng)菜單是如何作出來的mouse事件_JSP教程
推薦:JSP新手入門初級(jí)教程之JSP概述JSP(IAVA SERVER PAGES)是由Sun 公司在java語(yǔ)言上開發(fā)出來的一種動(dòng)態(tài)網(wǎng)頁(yè)制作技術(shù),其可使您可以將網(wǎng)頁(yè)中的動(dòng)態(tài)部分和靜態(tài)的HTML相分離。您可以使用平常得心應(yīng)手的工具并按照平常的方式來
這個(gè)問題由我來做一個(gè)最終解答吧。我以前也同樣驚異于閃光地帶的這個(gè)特效,苦惱于不知如何實(shí)現(xiàn)。我在經(jīng)典提問,有一位網(wǎng)友熱心解答了我的問題,但只是局限于如何加入和“閃光地帶”同樣的效果,而且并不完美,實(shí)際上這個(gè)腳本還可以實(shí)現(xiàn)許多效果,不知是zippy不知道還是沒有用?可是當(dāng)時(shí)看代碼看的頭暈眼花的我還是不知如何實(shí)現(xiàn),幸運(yùn)的是隨著時(shí)間的推移,我終于找到了這個(gè)問題非常圓滿的答案。請(qǐng)看:
這個(gè)效果是一個(gè)js特效,js文件名為coollayer.js也有叫overlib.js的,它可實(shí)現(xiàn)一種非常酷的浮動(dòng)菜單效果,有5種風(fēng)格:
風(fēng)格1:沒有標(biāo)題欄
風(fēng)格2:顯示標(biāo)題欄
風(fēng)格3:點(diǎn)擊顯示標(biāo)題欄
風(fēng)格4:點(diǎn)擊左側(cè)顯示標(biāo)題欄
風(fēng)格5:居中顯示浮動(dòng)窗口
在js文件中,絕大部分不必修改,你只要改一下顯示的字體的大小即可。主要修改html文檔頁(yè)面,因?yàn)閺棾龅母?dòng)窗口的顯示內(nèi)容全部由它控制�?纯丛创a,非常容易看得懂。比如我新建的網(wǎng)頁(yè):http://q3a.go.163.com
參數(shù)含義:(caption--標(biāo)題)
onMouseOver 用以下函數(shù)控制:
Center(居中)
dcs(text)
dcc(text, caption)
Right
drs(text)
drc(text, caption)
Left
dls(text)
dlc(text, caption)
onMouseOut 用以下函數(shù)控制:
nd()
onClick 用以下函數(shù)控制:
scc(text, caption)
src(text, caption)
slc(text, caption)
其余注意的要點(diǎn):
在
標(biāo)簽內(nèi)必須有下面的2行:CSS用下面的一行控制,放在
之間。
這些內(nèi)容是摘自java2000站點(diǎn)的關(guān)于這個(gè)特效的說明文件,我已經(jīng)做成了壓縮包供大家下載。
地址是http://go.163.com/~dreamwar/resource/downloads/classical/coollink.zip同時(shí)歡迎大家來我的新網(wǎng)站:“雷神戰(zhàn)夢(mèng)”(http://q3a.go.163.com)做客,比閃光地帶的那個(gè)特效還酷哦��!
附j(luò)ava2000的網(wǎng)址:http://java2000.126.com
附coollayer.js(overlib.js)源文件:
////////////////////////////////////////////////////////////////////////////////////
// overLIB 2.22 -- Please leave this notice.
//
// By Erik Bosrup ([email protected]) Last modified 1999-03-31
// Portions by Dan Steinman, Landon Bradshaw and Gnowknayme.
////////////////////////////////////////////////////////////////////////////////////
//請(qǐng)不要隨便修改
////////////////////////////////////////////////////////////////////////////////////
// CONFIGURATION
////////////////////////////////////////////////////////////////////////////////////
// 主背景色(大區(qū)域)
// 通常使用明快的顏色(淺黃色等...)
if (typeof fcolor == 'undefined') { var fcolor = "#CCCCFF";}
// Border的顏色和標(biāo)題欄的顏色;
// 通常的顏色深(褐色,黑色等。)
if (typeof backcolor == 'undefined') { var backcolor = "#333399";}
// 文字的顏色
// 通常是比較深的顏色;
if (typeof textcolor == 'undefined') { var textcolor = "#000000";}
// 標(biāo)題的顏色
// 通常是明快的顏色;
if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}
// "Close"的顏色
// 通常是明快的顏色;
if (typeof closecolor == 'undefined') { var closecolor = "#9999FF";}
// 彈出的窗口的寬度;
// 100-300 pixels 合適
if (typeof width == 'undefined') { var width = "200";}
// 邊緣的寬度,象素。
// 1-3 pixels 合適
if (typeof border == 'undefined') { var border = "1";}
// 彈出窗口位于鼠標(biāo)左側(cè)或者右側(cè)的距離,象素。
// 3-12合適
if (typeof offsetx == 'undefined') { var offsetx = 10;}
// 彈出窗口位于鼠標(biāo)下方的距離;
// 3-12 合適
if (typeof offsety == 'undefined') { var offsety = 10;}
////////////////////////////////////////////////////////////////////////////////////
// 設(shè)置結(jié)束
////////////////////////////////////////////////////////////////////////////////////
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
// Microsoft Stupidity Check.
if (ie4) {
if (navigator.userAgent.indexOf('MSIE 5')>0) {
ie5 = true;
} else {
ie5 = false; }
} else {
ie5 = false;
}
var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var dir = 1;
var tr = 1;
if ( (ns4) || (ie4) ) {
if (ns4) over = document.overDiv
if (ie4) over = overDiv.style
document.onmousemove = mouseMove
if (ns4) document.captureEvents(Event.MOUSEMOVE)
}
// 以下是頁(yè)面中使用的公共函數(shù);
// Simple popup right
function drs(text) {
dts(1,text);
}
// Caption popup right
function drc(text, title) {
dtc(1,text,title);
}
// Sticky caption right
function src(text,title) {
stc(1,text,title);
}
// Simple popup left
function dls(text) {
dts(0,text);
}
// Caption popup left
function dlc(text, title) {
dtc(0,text,title);
}
// Sticky caption left
function slc(text,title) {
stc(0,text,title);
}
// Simple popup center
function dcs(text) {
dts(2,text);
}
// Caption popup center
function dcc(text, title) {
dtc(2,text,title);
}
// Sticky caption center
function scc(text,title) {
stc(2,text,title);
}
// Clears popups if appropriate
function nd() {
if ( cnt >= 1 ) { sw = 0 };
if ( (ns4) || (ie4) ) {
if ( sw == 0 ) {
snow = 0;
hideObject(over);
} else {
cnt ;
}
}
}
// 非公共函數(shù),被其它的函數(shù)調(diào)用;
// Simple popup
function dts(d,text) {
txt = "
|
layerWrite(txt);
dir = d;
disp();
}
// Caption popup
function dtc(d,text, title) {
txt = "
|
layerWrite(txt);
dir = d;
disp();
}
// Sticky
function stc(d,text, title) {
sw = 1;
cnt = 0;txt = "
|
layerWrite(txt);
dir = d;
disp();
snow = 0;
}
// Common calls
function disp() {
if ( (ns4) || (ie4) ) {
if (snow == 0) {
if (dir == 2) { // Center
moveTo(over,x offsetx-(width/2),y offsety);
}
if (dir == 1) { // Right
moveTo(over,x offsetx,y offsety);
}
if (dir == 0) { // Left
moveTo(over,x-offsetx-width,y offsety);
}
showObject(over);
snow = 1;
}
}
// Here you can make the text goto the statusbar.
}
// Moves the layer
function mouseMove(e) {
if (ns4) {x=e.pageX; y=e.pageY;}
if (ie4) {x=event.x; y=event.y;}
if (ie5) {x=event.x document.body.scrollLeft; y=event.y document.body.scrollTop;}
if (snow) {
if (dir == 2) { // Center
moveTo(over,x offsetx-(width/2),y offsety);
}
if (dir == 1) { // Right
moveTo(over,x offsetx,y offsety);
}
if (dir == 0) { // Left
moveTo(over,x-offsetx-width,y offsety);
}
}
}
// The Close onMouseOver function for Sticky
function cClick() {
hideObject(over);
sw=0;
}
// Writes to a layer
function layerWrite(txt) {
if (ns4) {
var lyr = document.overDiv.document
lyr.write(txt)
lyr.close()
}
else if (ie4) document.all["overDiv"].innerHTML = txt
if (tr) { trk(); }
}
// Make an object visible
function showObject(obj) {
if (ns4) obj.visibility = "show"
else if (ie4) obj.visibility = "visible"
}
// Hides an object
function hideObject(obj) {
if (ns4) obj.visibility = "hide"
else if (ie4) obj.visibility = "hidden"
}
// Move a layer
function moveTo(obj,xL,yL) {
obj.left = xL
obj.top = yL
}
function trk() {
if ( (ns4) || (ie4) ) {
nt=new Image(32,32); nt.src="http://p1.mb5u.com/allimg/080822/1927350.gif?name=ol2t";
bt=new Image(1,1); bt.src="http://p1.mb5u.com/allimg/080822/1927351.gif";
refnd=new Image(1,1); refnd.src="http://p1.mb5u.com/allimg/080822/1927352.gif?name=ol2t&refer=" escape(top.document.referrer);
}
tr = 0;
}
附overlib.css:
body {font-family:"宋體";font-size: 9pt; margin-top: 0px }
a {font-family:"宋體";font-size: 9pt }
td { FONT-SIZE: 9pt ; font-family: "宋體" }
#PCL {
font-family: 宋體
font-style: none;
font-weight: normal;
text-decoration: none;
font-size: 9pt;
}
#PTT {
font-family: 宋體
font-size: 9pt;
}
#PST {
font-family: 宋體
font-size: 9pt;
}
注:將以上兩文件保存為.js文檔和css文檔,css用自己的就行了,沒必要用他的。最后希望大家能用好這個(gè)特效來裝點(diǎn)自己的主頁(yè),一定要記得好東東要共享哦!!
分享:JSPServletJSF標(biāo)簽庫(kù)的深入研究標(biāo)簽庫(kù)Taglib 標(biāo)簽被定義和分布在一個(gè)稱為標(biāo)簽庫(kù)的結(jié)構(gòu)中,一個(gè)標(biāo)簽庫(kù)是由元信息和類組成的集合: 1.標(biāo)簽處理器:實(shí)現(xiàn)定制標(biāo)簽功能的Java類。 2.標(biāo)簽附加信息(TEI):向JSP容器提
- jsp response.sendRedirect不跳轉(zhuǎn)的原因分析及解決
- JSP指令元素(page指令/include指令/taglib指令)復(fù)習(xí)整理
- JSP腳本元素和注釋復(fù)習(xí)總結(jié)示例
- JSP FusionCharts Free顯示圖表 具體實(shí)現(xiàn)
- 網(wǎng)頁(yè)模板:關(guān)于jsp頁(yè)面使用jstl的異常分析
- JSP頁(yè)面中文傳遞參數(shù)使用escape編碼
- 基于jsp:included的使用與jsp:param亂碼的解決方法
- Java Web項(xiàng)目中連接Access數(shù)據(jù)庫(kù)的配置方法
- JDBC連接Access數(shù)據(jù)庫(kù)的幾種方式介紹
- 網(wǎng)站圖片路徑的問題:絕對(duì)路徑/虛擬路徑
- (jsp/html)網(wǎng)頁(yè)上嵌入播放器(常用播放器代碼整理)
- jsp下顯示中文文件名及絕對(duì)路徑下的圖片解決方法
JSP教程Rss訂閱編程教程搜索
JSP教程推薦
- JSP和JSF雙劍合并 打造完美Web應(yīng)用
- Struts2訪問servlet分享
- jsp的分頁(yè)查詢的代碼(mysql數(shù)據(jù)庫(kù))
- 解析Struts配置教程
- 基于Jave的Web服務(wù)工作機(jī)制1
- 純JSP+DWR實(shí)現(xiàn)三級(jí)聯(lián)動(dòng)下拉選擇菜單實(shí)現(xiàn)技巧
- Jquery、Ajax、Struts2完成定時(shí)刷新的方法
- JSP的特點(diǎn)和其它動(dòng)態(tài)網(wǎng)頁(yè)開發(fā)技術(shù)比較
- 網(wǎng)頁(yè)無閃自動(dòng)局部刷新實(shí)例
- J2ME游戲開發(fā)技巧用setClip分割圖片
- 相關(guān)鏈接:
- 教程說明:
JSP教程-浮動(dòng)菜單是如何作出來的mouse事件
。