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

首頁 > 開發 > 綜合 > 正文

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

2024-07-21 02:14:19
字體:
來源:轉載
供稿:網友
  • 本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
  • 這個問題由我來做一個最終解答吧。我以前也同樣驚異于閃光地帶的這個特效,苦惱于不知如何實現。我在經典提問,有一位網友熱心解答了我的問題,但只是局限于如何加入和“閃光地帶”同樣的效果,而且并不完美,實際上這個腳本還可以實現許多效果,不知是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)

    其余注意的要點:

    在<body></body>標簽內必須有下面的2行:

    <div id="overdiv" style="position:absolute; visibility:hide; z-index:1;"></div>

    <script language="javascript" src="overlib.js"></script>

    css用下面的一行控制,放在<head></head>之間。

    <link rel="stylesheet" href="overlib.css" type="text/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 ([email protected]) 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 = "<table width="+width+" border=0 cellpadding="+border+" cellspacing=0 bgcolor=""+backcolor+""><tr><td><table width=100% border=0 cellpadding=2 cellspacing=0 bgcolor=""+fcolor+""><tr><td><font face="宋體" color=""+textcolor+"">"+text+"</font></td></tr></table></td></tr></table>"

    layerwrite(txt);

    dir = d;

    disp();

    }

    // caption popup

    function dtc(d,text, title) {

    txt = "<table width="+width+" border=0 cellpadding="+border+" cellspacing=0 bgcolor=""+backcolor+""><tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr><td><span id="ptt"><font color=""+capcolor+"">"+title+"</font></b></span></td></tr></table><table width=100% border=0 cellpadding=2 cellspacing=0 bgcolor=""+fcolor+""><tr><td><span id="pst"><font color=""+textcolor+"">"+text+"</font><span></td></tr></table></td></tr></table>"

    layerwrite(txt);

    dir = d;

    disp();

    }

    // sticky

    function stc(d,text, title) {

    sw = 1;

    cnt = 0;
     

    txt = "<table width="+width+" border=0 cellpadding="+border+" cellspacing=0 bgcolor=""+backcolor+""><tr><td><table width=100% border=0 cellpadding=0 cellspacing=0><tr><td><span id="ptt"><font color=""+capcolor+"">"+title+"</font></b></span></td><td align=right><a href="/" onmouseover="cclick();" id="pcl"><font color=""+closecolor+"">close</font></a></td></tr></table><table width=100% border=0 cellpadding=2 cellspacing=0 bgcolor=""+fcolor+""><tr><td><span id="pst"><font color=""+textcolor+"">"+text+"</font><span></td></tr></table></td></tr></table>"

    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://www.nedstat.nl/cgi-bin/nedstat.gif?name=ol2t";

    bt=new image(1,1); bt.src="http://webdesign.chinaitlab.com/uploadfiles_8014/200605/20060512113425323.gif";

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

    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 永春县| 全州县| 博客| 沁水县| 牡丹江市| 镶黄旗| 搜索| 会昌县| 濮阳市| 天全县| 尚志市| 定远县| 淅川县| 夹江县| 左贡县| 澎湖县| 城步| 基隆市| 洪湖市| 中超| 漯河市| 靖西县| 望都县| 贵溪市| 阳原县| 商城县| 潮州市| 湖北省| 措勤县| 彰武县| 封丘县| 句容市| 措美县| 进贤县| 沂水县| 闻喜县| 静宁县| 阜新市| 大安市| 桦川县| 平湖市|