国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

浮動菜單是如何作出來的mouse事件

2024-09-05 00:17:06
字體:
來源:轉載
供稿:網友

這個問題由我來做一個最終解答吧。我以前也同樣驚異于閃光地帶的這個特效,苦惱于不知如何實現。我在經典提問,有一位網友熱心解答了我的問題,但只是局限于如何加入和“閃光地帶”同樣的效果,而且并不完美,實際上這個腳本還可以實現許多效果,不知是zippy不知道還是沒有用?可是當時看代碼看的頭暈眼花的我還是不知如何實現,幸運的是隨著時間的推移,我終于找到了這個問題非常圓滿的答案。請看:

這個效果是一個js特效,js文件名為coollayer.js也有叫overlib.js的,它可實現一種非常酷的浮動菜單效果,有5種風格:

風格1:沒有標題欄

風格2:顯示標題欄

風格3:點擊顯示標題欄

風格4:點擊左側顯示標題欄

風格5:居中顯示浮動窗口

在js文件中,絕大部分不必修改,你只要改一下顯示的字體的大小即可。主要修改html文檔頁面,因為彈出的浮動窗口的顯示內容全部由它控制。看看源代碼,非常容易看得懂。比如我新建的網頁:http://q3a.go.163.com

參數含義:(caption--標題)

onMouseOver 用以下函數控制:

Center(居中)

dcs(text)

dcc(text, caption)

Right

drs(text)

drc(text, caption)

Left

dls(text)

dlc(text, caption)

onMouseOut 用以下函數控制:

nd()

onClick 用以下函數控制:

scc(text, caption)

src(text, caption)

slc(text, caption)

其余注意的要點:

在標簽內必須有下面的2行:

CSS用下面的一行控制,放在之間。

這些內容是摘自java2000站點的關于這個特效的說明文件,我已經做成了壓縮包供大家下載。

地址是http://go.163.com/~dreamwar/resource/downloads/classical/coollink.zip同時歡迎大家來我的新網站:“雷神戰夢”(http://q3a.go.163.com)做客,比閃光地帶的那個特效還酷哦!!

附java2000的網址:http://java2000.126.com

附coollayer.js(overlib.js)源文件:

////////////////////////////////////////////////////////////////////////////////////

// overLIB 2.22 -- Please leave this notice.

//

// By Erik Bosrup (erik@bosrup.com) Last modified 1999-03-31

// Portions by Dan Steinman, Landon Bradshaw and Gnowknayme.

////////////////////////////////////////////////////////////////////////////////////

//請不要隨便修改

////////////////////////////////////////////////////////////////////////////////////

// CONFIGURATION

////////////////////////////////////////////////////////////////////////////////////

// 主背景色(大區域)

// 通常使用明快的顏色(淺黃色等...)

if (typeof fcolor == 'undefined') { var fcolor = "#CCCCFF";}

// Border的顏色和標題欄的顏色;

// 通常的顏色深(褐色,黑色等。)

if (typeof backcolor == 'undefined') { var backcolor = "#333399";}

// 文字的顏色

// 通常是比較深的顏色;

if (typeof textcolor == 'undefined') { var textcolor = "#000000";}

// 標題的顏色

// 通常是明快的顏色;

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";}

// 彈出窗口位于鼠標左側或者右側的距離,象素。

// 3-12合適

if (typeof offsetx == 'undefined') { var offsetx = 10;}

// 彈出窗口位于鼠標下方的距離;

// 3-12 合適

if (typeof offsety == 'undefined') { var offsety = 10;}

////////////////////////////////////////////////////////////////////////////////////

// 設置結束

////////////////////////////////////////////////////////////////////////////////////

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)

}

// 以下是頁面中使用的公共函數;

// 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 ;

}

}

}

// 非公共函數,被其它的函數調用;

// Simple popup

function dts(d,text) {

txt = "

" text "
"

layerWrite(txt);

dir = d;

disp();

}

// Caption popup

function dtc(d,text, title) {

txt = "

" title "
" text "
"

layerWrite(txt);

dir = d;

disp();

}

// Sticky

function stc(d,text, title) {

sw = 1;

cnt = 0;

txt = "

" title "Close
" text "
"

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.CuoXIn.com/allimg/080822/1927350.gif?name=ol2t";

bt=new Image(1,1); bt.src="http://p1.CuoXIn.com/allimg/080822/1927351.gif";

refnd=new Image(1,1); refnd.src="http://p1.CuoXIn.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用自己的就行了,沒必要用他的。最后希望大家能用好這個特效來裝點自己的主頁,一定要記得好東東要共享哦!!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 松江区| 赤水市| 增城市| 搜索| 恭城| 威宁| 平乡县| 玛沁县| 名山县| 台安县| 封开县| 城步| 晋城| 扎鲁特旗| 青川县| 蕲春县| 咸丰县| 嘉义市| 错那县| 新建县| 台中市| 楚雄市| 四川省| 额尔古纳市| 望城县| 安仁县| 康马县| 文山县| 镇赉县| 汉沽区| 上蔡县| 钟山县| 册亨县| 紫金县| 容城县| 龙南县| 西贡区| 无为县| 察雅县| 清徐县| 甘肃省|