×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

我得到后面的code了,怎么谢我.......

本文发表在 rolia.net 枫下论坛/******************************************************************************
* dhtmllib.js *
* *
* Copyright 1999 by Mike Hall. *
* Web address: http://www.brainjar.com *
* Last update: November 30, 1999. *
* *
* Provides basic functions for DHTML positioned elements which will work on *
* both Netscape Communicator and Internet Explorer browsers (version 4.0 and *
* up). *
******************************************************************************/

// Determine browser.

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;

//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------

function hideLayer(layer) {

if (isMinNS4)
layer.visibility = "hide";
if (isMinIE4)
layer.style.visibility = "hidden";
}

function showLayer(layer) {

if (isMinNS4)
layer.visibility = "show";
if (isMinIE4)
layer.style.visibility = "visible";
}

function isVisible(layer) {

if (isMinNS4 && layer.visibility == "show")
return(true);
if (isMinIE4 && layer.style.visibility == "visible")
return(true);

return(false);
}

//-----------------------------------------------------------------------------
// Layer positioning.
//-----------------------------------------------------------------------------

function moveLayerTo(layer, x, y) {

if (isMinNS4)
layer.moveTo(x, y);
if (isMinIE4) {
layer.style.left = x;
layer.style.top = y;
}
}

function moveLayerBy(layer, dx, dy) {

if (isMinNS4)
layer.moveBy(dx, dy);
if (isMinIE4) {
layer.style.pixelLeft += dx;
layer.style.pixelTop += dy;
}
}



function getzIndex(layer) {

if (isMinNS4)
return(layer.zIndex);
if (isMinIE4)
return(layer.style.zIndex);

return(-1);
}

function setzIndex(layer, z) {

if (isMinNS4)
layer.zIndex = z;
if (isMinIE4)
layer.style.zIndex = z;
}


//-----------------------------------------------------------------------------
// Window and page properties.
//-----------------------------------------------------------------------------

function getWindowWidth() {

if (isMinNS4)
return(window.innerWidth-6);
if (isMinIE4)
return(document.body.clientWidth);
return(-1);
}

function getPageWidth() {

if (isMinNS4)
return(document.width);
if (isMinIE4)
return(document.body.scrollWidth);
return(-1);
}

function getOffset()
{
var wid = getWindowWidth();

if (isMinNS4) {
if (wid <= 779) { return 0 ; }
if (wid > 779) { return (wid -779)/2-6 ; }
}
if (isMinIE4) {
if (wid <= 779) { return 0 ; }
if (wid > 779) { return (wid -779)/2 ; }
}
}更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 有DHTML的高手吗?想问个动态菜单的问题->
    就是常见的菜单, 鼠标移到某个按钮上面, 就会出现下拉式的子菜单. 通常子菜单是隐形的DIV. 如果鼠标从按钮的下方移到子菜单上, 子菜单是保持可见的. 但鼠标从按钮其他方向离开, 子菜单就重新隐藏起来. 我的问题是怎么判断鼠标从按钮的哪个方向离开?
    • 我可不是高手,凭感觉说一句:不用判断方向,只需知道鼠标是否进入子菜单就可以了。所以,在子菜单的event里面判断就可以了。
      • 不行, 我在按钮中设了onmouseout=[隐藏子菜单], 光标没法移到子菜单上去
        • 加个判断,如果已经有子菜单了,就隐藏,否则就显示。效果是,如果你的鼠标一略而过,子菜单会哗哗地一显而没。我在有的site上见过。
          • 加一个DURATION TIMER 可以解决这个问题,但是我不认同不WEB PAGE搞的太复杂,象APPLICATION了. ANYWAY THERE IS ALWAYS A WAY TO SOLIVE THESE KINDS OF MESS. ^_^
        • 关键是定义坐标。但我发现这样设计出的很难同时适用于IE和NS。而且屏幕的Resolution定义很重要,要根据不同的resolution定义不同的坐标,太繁。
    • 就象萝卜秧说的,一般不判断从哪个方向离开,只要鼠标离开子菜单的坐标范围,子菜单就关闭。
    • Hope this URL helps
    • 先谢各位. 在这个页面上的菜单做得是比较完美的(www.cncglobal.com), 它的script似乎很简单, 也没有萝卜央说的判断. 但我研究了半天还是没得出结果. 哪位眼力好的请帮忙给看看
      • 我看是不管从哪个方向进入该区域,子菜单都会显示啊。
      • 它用了两个event, mouseover and mouseout,你查查两个事件有什么区别?哪个先发生?
        • see the source code
          onmouseover="changeV('employerDiv');" onmouseout="changeV('employerDiv'): 两个event调用了同一个函数,必然在函数里面有些判断或别的做法。

          对于子菜单:
          onmouseover="changeC('employer1','link1h');" onmouseout="changeC('employer1','link1');"
          只不过一个变highlight,一个变回来而已。
          关键是上面的mouseout和下面的mouseover如何衔接上的。
      • 很不幸,你用普通方法看不到 Javascript code.....
        • 用Netscape可看source。粗看一下,它是结合javascript and CSS 一起,absolute 坐标。而且该菜单只适用IE。
      • this one?
      • check in the .js
        function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
        var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
        for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
        v=(v=='show')?'visible':(v='hide')?'hidden':v;
        if(obj)obj.style.visibility=v;}} else{
        for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
        obj.visibility=v; }}
        }
      • the functions: changeV and changeC are hidden in javascripts: interscripts.js and dhtmllib.js, which you can not read from the page.
        • 直接敲入URL,便可下载。
          • Thank you very much.
        • 我知道这两个FUNCTION, 但没看出里面有判断鼠标从哪个方向离开. 因为用ONMOUSEOUT, 我做的网页里鼠标一离开触发菜单的BUTTON, 菜单就消失了
      • 我得到后面的code了,怎么谢我.......
        本文发表在 rolia.net 枫下论坛/******************************************************************************
        * dhtmllib.js *
        * *
        * Copyright 1999 by Mike Hall. *
        * Web address: http://www.brainjar.com *
        * Last update: November 30, 1999. *
        * *
        * Provides basic functions for DHTML positioned elements which will work on *
        * both Netscape Communicator and Internet Explorer browsers (version 4.0 and *
        * up). *
        ******************************************************************************/

        // Determine browser.

        var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
        parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
        var isMinIE4 = (document.all) ? 1 : 0;
        var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;

        //-----------------------------------------------------------------------------
        // Layer visibility.
        //-----------------------------------------------------------------------------

        function hideLayer(layer) {

        if (isMinNS4)
        layer.visibility = "hide";
        if (isMinIE4)
        layer.style.visibility = "hidden";
        }

        function showLayer(layer) {

        if (isMinNS4)
        layer.visibility = "show";
        if (isMinIE4)
        layer.style.visibility = "visible";
        }

        function isVisible(layer) {

        if (isMinNS4 && layer.visibility == "show")
        return(true);
        if (isMinIE4 && layer.style.visibility == "visible")
        return(true);

        return(false);
        }

        //-----------------------------------------------------------------------------
        // Layer positioning.
        //-----------------------------------------------------------------------------

        function moveLayerTo(layer, x, y) {

        if (isMinNS4)
        layer.moveTo(x, y);
        if (isMinIE4) {
        layer.style.left = x;
        layer.style.top = y;
        }
        }

        function moveLayerBy(layer, dx, dy) {

        if (isMinNS4)
        layer.moveBy(dx, dy);
        if (isMinIE4) {
        layer.style.pixelLeft += dx;
        layer.style.pixelTop += dy;
        }
        }



        function getzIndex(layer) {

        if (isMinNS4)
        return(layer.zIndex);
        if (isMinIE4)
        return(layer.style.zIndex);

        return(-1);
        }

        function setzIndex(layer, z) {

        if (isMinNS4)
        layer.zIndex = z;
        if (isMinIE4)
        layer.style.zIndex = z;
        }


        //-----------------------------------------------------------------------------
        // Window and page properties.
        //-----------------------------------------------------------------------------

        function getWindowWidth() {

        if (isMinNS4)
        return(window.innerWidth-6);
        if (isMinIE4)
        return(document.body.clientWidth);
        return(-1);
        }

        function getPageWidth() {

        if (isMinNS4)
        return(document.width);
        if (isMinIE4)
        return(document.body.scrollWidth);
        return(-1);
        }

        function getOffset()
        {
        var wid = getWindowWidth();

        if (isMinNS4) {
        if (wid <= 779) { return 0 ; }
        if (wid > 779) { return (wid -779)/2-6 ; }
        }
        if (isMinIE4) {
        if (wid <= 779) { return 0 ; }
        if (wid > 779) { return (wid -779)/2 ; }
        }
        }更多精彩文章及讨论,请光临枫下论坛 rolia.net
        • 看样子上面的site也是copy别人的code啊。:-)
          • DHTML 不就是抄来抄去吗? 所以我们才不太会写DHTML....
      • 另一部分
        本文发表在 rolia.net 枫下论坛function changeC(daItem,daStyle) {
        document.getElementById(daItem).className = daStyle;
        }

        function changeV(daLayer) {
        if (document.getElementById(daLayer).style.visibility == "hidden") {
        document.getElementById(daLayer).style.visibility = "visible";
        }else{
        document.getElementById(daLayer).style.visibility = "hidden";
        }
        }

        function swapI(myId,myNew) {
        document.getElementById(myId).src = myNew;
        }

        function MM_findObj(n, d) { //v3.0
        var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
        }

        function tmt_findObj(n){
        var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
        x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
        }else{x=document.getElementById(n)}return x;
        }

        function MM_showHideLayers() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
        var i,p,v,obj,args=MM_showHideLayers.arguments;if(document.getElementById){
        for (i=0; i<(args.length-2); i+=3){ obj=tmt_findObj(args[i]);v=args[i+2];
        v=(v=='show')?'visible':(v='hide')?'hidden':v;
        if(obj)obj.style.visibility=v;}} else{
        for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
        obj.visibility=v; }}
        }

        function MM_preloadImages() { //v3.0
        var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
        }

        function MM_swapImgRestore() { //v3.0
        var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
        }


        function MM_swapImage() { //v3.0
        var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
        if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
        }

        function MM_jumpMenu(targ,selObj,restore){ //v3.0
        eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
        if (restore) selObj.selectedIndex=0;
        }

        function MM_openBrWindow(theURL,winName,features) { //v2.0
        window.open(theURL,winName,features);
        }

        function jsv_check_key(obj)
        {

        var ele = new String(document.jssv.js_sv.value);
        if (ele.length<=1) {
        alert ("Please enter valid search criteria.");
        return false;
        }
        else {
        return true;
        }
        }更多精彩文章及讨论,请光临枫下论坛 rolia.net
        • 如何得到的?是否要enable什么setting啊?多谢!
          • http://www.cncglobal.com/interface/libraries/interscripts.js
          • 给CNC网站的人打了个电话,team leader说要下班了,我说不行,我们这儿有人要急着用,马上把文件给我传过来...他不太愿意,但又不敢惹我,所以磨蹭半天给传过来了.....你信吗 :-)
            其实很简单,根据路径直接指向script文件就可以了....
            • 我当然信啦!你老大不是在NO.1 e-commerce公司里担任要职嘛?这点小事儿还不是手到擒来。。。呵呵。
              多谢!
    • 简单偷懒的方法是去DW一个软件:Xara WebStyle, 做一个Menu或者NavBar几分钟就解决问题,自动生成js代码和HTML文件。
    • 已经找到解决办法了: 我原来以为POPUP MENU的边缘正好接在触发按钮的下沿, 实际上只要把POPUP的DIV范围延伸至包含整个触发按钮就行了. 谢谢各位