Menu and submenu : Menu « GUI Components « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Event
7. Event onMethod
8. Form Control
9. GUI Components
10. HTML
11. Javascript Collections
12. Javascript Objects
13. Language Basics
14. Node Operation
15. Object Oriented
16. Page Components
17. Security
18. Style Layout
19. Table
20. Utilities
21. Window Browser
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
JavaScript DHTML » GUI Components » Menu 
Menu and submenu

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>xmenu-xlayer</title>
    
    <meta name="KEYWORDS" content="">
    <meta name="DESCRIPTION" content="">

<style type="text/css">
  <!--
  body
  {
    background-color: #ffffff;
    color: #000000;
    font-size: 12px;
    font-family: Arial, Helvetica;
  }

  p
  {
    color: #a1a1a1;
    font-weight: bold;
  }

  a
  {
    font-family: Arial, Helvetica;
    text-decoration: none
  }
  a:active
  {
    color: #a1a1a1
  }
  a:link
  {
    color: #a1a1a1
  }
  a:visited
  {
    color: #a1a1a1
  }
  a:hover
  {
    color: #cccccc;
    text-decoration: none;
  }

  .orange
  {
    background-color: #ff7f00;
  }
  .dark_orange
  {
    background-color: #ff5500;
  }
  a.navigation_links
  {
    font-family: Arial, Helvetica, sans serif; 
    font-size:10px; 
    color: #fadada;
    font-weight: 600;
  }
  a:hover.navigation_links
  {
    font-family: Arial, Helvetica, sans serif; 
    font-size:10px; 
    color:white;
    font-weight: 600;
  }
  .content
  {
    font-family: Arial, Helvetica, sans serif;
    background-color: #ffffff;
    color: #000000;
    font-size: 12px;
  }
  -->


    
    
    </style>
<!-- Browser.js -->
    <script language="javascript">
// created by: Andre Dietisheim (dietisheim@sphere.ch)
// created: 2001-31-12
// modified by: Andre Dietisheim (dietisheim@sphere.ch)
// modified: 2004-01-28
// version: 0.8.0

function Browserbrowsers 
{
  this.browsers = browsers;  // browser detection array
  this.createBooleans();
}

Browser.prototype.createBooleans = function() 
{
  var name = navigator.appName;
  var cname = navigator.appCodeName;
  var usragt = navigator.userAgent;
  var ver = navigator.appVersion;
  for i = 0; i < this.browsers.length; i++ 
  {
    var browserArray = this.browsers]// browsers-array

    var sCheck = browserArray]// 'logical expr' that detects the browser
    var sCurrentVersion = browserArray]// 'regexp' that gets current version
    var sBrand = browserArray]// browser-obj 'property' (is.xx)
    var availableVersions = browserArray]// 'versions' to check for

    if evalsCheck ) )
    // browser recognized
      eval"this." + sBrand + " = true" )// browser-obj property (is.xx)
      var regexp, ver, sMinorVersion, sMajorVersion;
      regexp = new RegExpsCurrentVersion );
      regexp.execusragt )// parse navigator.userAgent
      var sMajorVersion = RegExp.$1;
      var sMinorVersion = RegExp.$2;

      for j = 0; j < availableVersions.length; j++ )
      {
        if parseFloat(availableVersions]) <= evalsMajorVersion + "." + sMinorVersion ) )
        // upper versions
          eval"this." + sBrand + availableVersions].substr0+ availableVersions].substr2"up = true" );
        }
        if parseFloat(availableVersions]) == evalsMajorVersion + "." + sMinorVersion ) ) 
        /// current version
          eval"this." + sBrand + availableVersions].substr0+ availableVersions].substr2"= true" );
        }
      }
    }
  }
}

is = new Browser 
[
  // Internet Explorer Windows ---
  "iewin",
    "cname.indexOf( 'Mozilla' ) >= 0 && name.indexOf( 'Microsoft Internet Explorer' ) >= 0 && usragt.indexOf( 'MSIE' ) >= 0 && usragt.indexOf( 'Opera' ) < 0 && usragt.indexOf( 'Windows' ) >= 0"// IE detection expression
    "MSIE.([0-9]).([0-9])",  // regexpr for version (in navigator.userAgent)
    "5""5.5""6" ] ],  // published versions
  // Internet Explorer Macintosh ---
  "iemac",
    "cname.indexOf( 'Mozilla' ) >= 0 && name.indexOf( 'Microsoft Internet Explorer' ) >= 0 && usragt.indexOf( 'MSIE' ) >= 0 && usragt.indexOf('Opera') < 0 && usragt.indexOf('Mac') >= 0",
    "MSIE.([0-9]).([0-9])",
    "5""5.1""5.2" ] ],
  // Gecko (Mozilla, Galeon, Firebird, Netscape >=6.x) ---
  "gk"
    "cname.indexOf( 'Mozilla' ) >= 0 && name.indexOf( 'Netscape' ) >= 0 && usragt.indexOf( 'Gecko' ) >= 0 && usragt.indexOf( 'Safari' ) < 0",
    "[rv[:| ]*([0-9]).([0-9])|Galeon\/([0-9]).([0-9])]",
    "0.7""0.8""0.9""1.0""1.1""1.2""1.3""1.4""1.5""1.6" ] ],
  // Netscape Navigator ---
  "nn",
    "cname.indexOf( 'Mozilla' ) >= 0 && name.indexOf( 'Netscape' ) >=0 && parseInt( ver ) <= 4",
    "([0-9]).([0-9])",
    "4""4.5""4.7""4.8" ] ],
  // Opera ---
  "op",
    "cname.indexOf( 'Mozilla' ) >= 0 && ( name.indexOf( 'Microsoft Internet Explorer' ) >=0 || name.indexOf( 'Opera' ) >= 0 ) && usragt.indexOf( 'Opera' ) >= 0",
    "Opera.([0-9]).([0-9])",
    "5""5.1""6""7""7.1""7.2" ] ],
  // Safari ---
  "sf",
    "cname.indexOf( 'Mozilla' ) >= 0 && name.indexOf( 'Netscape' ) >=0 && usragt.indexOf('AppleWebKit' ) >= 0 && usragt.indexOf('Safari') >= 0",
    "AppleWebKit\/([0-9])"
    "Konqueror\/([0-9]\.[0-9])",
    "48""85" ] ],
  // Konqueror ---
  "kq",
    "cname.indexOf( 'Mozilla' ) >= 0 && name.indexOf( 'Konqueror' ) >= 0 && usragt.indexOf( 'Konqueror' ) >= 0",
    "Konqueror\/([0-9]).([0-9]*)",
    "2.2""3""3.1" ] ]
] );

    
    </script>
<!-- XlayerParent.js -->
    <script language="javascript">
// created by: Andre Dietisheim (dietisheim@sphere.ch)
// created:  2001-12-20
// modified by: Andre Dietisheim (dietisheim@sphere.ch)
// modified: 2004-02-06
// version: 1.4.0

function XlayerParentsLayerId, sImg, sDesc, iWidth, iHeight, sContent )
{
  // static var --------
  if!XlayerParent.prototype.instances XlayerParent.prototype.instances = new Array();
  XlayerParent.prototype.instancesXlayerParent.prototype.instances.length this;
  this.sId = this.createsLayerId, sImg, sDesc, iWidth, iHeight )
}

XlayerParent.prototype.create functionsLayerId, sImg, sDesc, iWidth, iHeight )
{
  this.sParentLayerId = sLayerId;
  this.sParentLayerXlayerId = sLayerId + "Xlayer"

  var sLayer = "";
  var content_str = '';

  if sImg )
    sContent = '<img src="' + sImg + '" width="' + iWidth + '" height="' + iHeight + '" border="0" >';
  else if sDesc )
    sContent = sDesc;

  // nn4up ----------
  if is.nn4up )
  {
    var sLayer = '<ilayer id="' + sLayerId + '" top=left=width=' + iWidth + ' height=' + iHeight + ' >' + ( ( sContent )? sContent : "" '</ilayer>';
    document.writesLayer );
    return sLayerId;
  }

  // iewin5up, iemac5up, gk --------
  else if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op6up )
  {
    var sLayer = '<div id="' + sLayerId + '" style="position:relative; width: ' + iWidth + 'px; height: ' + iHeight + 'px; ">'  ( ( sContent )? sContent : "" '</div>';
    document.writesLayer );
    return sLayerId;
  }
  else
  {
    return null;
  }
}

XlayerParent.prototype.getLayer = functionsLayerId )
{
  var layer = null;

  if sLayerId )
  {  // id supplied
    if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op6up )
      return document.getElementByIdsLayerId );
    else if is.nn4up )
      return document.layerssLayerId ];
  }
  else if !sLayerId )
  {  // null supplied
    if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op6up )
      return document.body;
    else if is.nn4up )
      return window;
  }
}


XlayerParent.prototype.getX = functionlayer )
{
  var x = 0;

  if is.nn4up )
  {
    if layer != window )      
      x = layer.pageX;
  }
  else if is.gk || is.iemac5up || is.iewin5up || is.sf || is.kq3up || is.op6up )
  {
    if layer != document.body )
    {
      currentX = 0;
      object = layer;
      while object )
      {
        currentX += object.offsetLeft;
        object = object.offsetParent;
      }
      x = currentX;
    }

    if is.iemac5up )
      x += parseInt"0" + document.body.currentStyle.marginLeft, 10  );

  }
  return x;
}


XlayerParent.prototype.getY = functionlayer )
{
  var y = 0;

  if is.nn4up )
  {
    if layer != window )  y = layer.pageY;
  }
  else if is.gk || is.iewin || is.iemac5up || is.sf || is.kq3up || is.op6up )
  {
    if layer != document.body )
    {
      currentY = 0;
      object = layer;
      while object )
      {
        currentY += object.offsetTop;
        object = object.offsetParent;
      }
      y = currentY;
    }
    if is.iemac5up )
      y += parseInt"0" + document.body.currentStyle.marginTop, 10  );
  }

  return y;
}


XlayerParent.prototype.getW = functionlayer )
{
  var w = 0;

  if is.nn4up )
  {
    if layer == window )
      return window.innerWidth;
    else
      return layer.clip.width;
  }
  else if is.gk || is.iemac5up || is.sf || is.kq3up || is.op6up )
  {
    if layer == document.body )
      return window.innerWidth;
    else
      return layer.offsetWidth;
  }
  else if is.iewin5up )
  {
    if layer == document.body )
      return document.body.clientWidth;
    else
      return layer.offsetWidth;
  }
}


XlayerParent.prototype.getH = functionlayer )
{
  var h = 0;

  if is.nn4up )
  {
    if layer == window )
      return window.innerHeight;
    else
      return layer.clip.height;
  }
  else if is.gk || is.iemac5up || is.sf || is.kq3up || is.op6up )
  {
    if layer == document.body )
      return window.innerHeight;
    else
      return layer.offsetHeight;
  }
  else if is.iewin5up )
  {
    if layer == document.body )
      return document.body.clientHeight;
    else
      return layer.offsetHeight;
  }
}
    
    </script>
<!-- Xlayer.js -->    
    <script language="javascript">
// created by: Andre Dietisheim (dietisheim@sphere.ch)
// created: 2001-12-20
// modified by: Andre Dietisheim (dietisheim@sphere.ch)
// modified: 2004-02-21
// version: 2.5.3

function XlayersParent, xlayerParent, x, y, offsetX, offsetY, w, h,  iClipTop, iClipRight, iClipBottom, iClipLeft, iZindex, bVisibility, sBgcolor, fading, events, sText, bBold, sAlign, iTopTextBorder, iRightTextBorder, iBottomTextBorder, iLeftTextBorder, sFgcolor, sHref, sIcon, iIconWidth, iIconHeight, iconBorder, sFontface, iFontsize, src , sSpacer )
{
  if !Xlayer.prototype.instances )
    Xlayer.prototype.instances = new Array();
  Xlayer.prototype.instancesXlayer.prototype.instances.length this// Store this Instance In static array

  this.index = Xlayer.prototype.instances.length - 1;
  this.sParent = sParent;
  this.parent = null;
  this.xlayerParent = xlayerParent;
  this.lyr = null;
  this.id = this.id || "Xlayer" this.index;
  this.x = x || 0;
  this.y = y || 0;
  this.offsetX = offsetX ||  0;
  this.offsetY = offsetY ||  0;
  this.w = w ||  0;
  this.h = h || 0;
  this.iClipTop = iClipTop || 0;
  this.iClipRight = iClipRight || w;
  this.iClipBottom = iClipBottom || h;
  this.iClipLeft = iClipLeft || 0;
  this.iZindex = iZindex || 0;
  this.bVisibility = bVisibility;
  this.sBgcolor = sBgcolor || "black";
  this.iOpacity = 0;
  this.sSpacer = sSpacer;

  // caption ---
  this.sText = sText || null;
  this.bBold = bBold || false;
  this.sAlign = sAlign || "center";
  this.iTopTextBorder = iTopTextBorder;
  this.iRightTextBorder = iRightTextBorder;
  this.iBottomTextBorder = iBottomTextBorder;
  this.iLeftTextBorder = iLeftTextBorder;
  this.sFgcolor = sFgcolor || "white";
  this.sHref = is.nn4up && !sHref )"#" : sHref; // nn4 always need a href to process clicks
  this.sFontface = sFontface || "Helvetica";
  this.iFontsize = iFontsize || 2;
  this.sIcon = sIcon ||  null;
  this.iIconWidth = iIconWidth || 0;
  this.iIconHeight = iIconHeight || 0;
  this.iconBorder = iconBorder || 0;

  // iframe ----
  this.iframe = null;
  this.scrollbars = null;
  this.src = src ||  null;
  this.events = events || null// array: event, func, event, func, ...
  this.fading =  fading || null// array: start, stop, steps, delay

  if is.op6up && !is.op7up // opera can't create dynamically
    this.writeDiv();
}

Xlayer.prototype.MOUSEOVER = "onmouseover";
Xlayer.prototype.MOUSEOUT = "onmouseout";
Xlayer.prototype.CLICK = "onclick";


Xlayer.prototype.create function() 
{
  this.parent = XlayerParent.prototype.getLayerthis.sParent )// parent = another layer or document.body
  this.parentCoordsOnly = XlayerParent.prototype.getLayerthis.xlayerParent.sId );
  if is.nn4up )
  {
    if this.w == "100%" )
      this.lyr = new Layerthis.parent.innerWidth, this.parent );
    else
      this.lyr = new Layerthis.w, this.parent );
  }
  else if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op7up )
  {
    this.lyr = document.createElement"DIV" )// create layer
    this.lyr.style.position = "absolute";
    this.lyr.style.overflow = "hidden";
    this.lyr.id = this.id;
    this.parent.appendChildthis.lyr )// insert into DOM
  }
  else if is.op6up && !is.op7up )
  // already created on instanciation (no dynamic creation possible)
    this.lyr = document.getElementByIdthis.id );
  }
  
  this.setVisibilitythis.bVisibility );
  this.setSizethis.w, this.h );
  this.setEventsthis.events );
  if !is.op6up && !is.op7up ) ) 
    this.setBodythis.getCaptionthis.sText, this.bBold, this.sIcon, this.iIconWidth, this.iIconHeight, this.iconBorder ) );
  this.setBgColorthis.sBgcolor );
  this.setFgColorthis.sFgcolor );
  this.setPosthis.x, this.y, this.offsetX, this.offsetY );
  this.setZindexthis.iZindex );
  this.fadethis.fading );
}

Xlayer.prototype.writeDiv = function()
{
  document.writeln'<div id="' + this.id + '" style="position:absolute;">' + this.getCaptionthis.sText, this.bBold, this.sIcon, this.iIconWidth, this.iIconHeight, this.iconBorder '</div>' );
}

Xlayer.prototype.kill = function()
{
  if is.nn4up )
  {
    for i = 0; i < document.layers.length ; i++ // scan trough layers-array in NN-DOM
    {
      this.setVisibilityfalse );
      if document.layers].id == this.lyr.id )  
      {
        index = i;
        //document.layers.splice(i, 1)
        //delete document.layers[i]
        document.layersnull;
        break;
      }
    }
  }
  else if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op7up )
  {
    var lyr;
    lyr = document.getElementByIdthis.lyr.id );
    document.body.removeChildlyr );
  }
  this.iOpacity = 0;
}

Xlayer.prototype.setFgColor = functioncolor )
{
  if this.sText )
  {
    this.sFgcolor = color;

    if is.nn4up )
      this.setBodythis.getCaptionthis.sText, this.bBold, this.sIcon, this.iIconWidth, this.iIconHeight, this.iconBorder ) );
    else if is.iewin5up || is.iemac5up || is.gk || is.sf  || is.kq3up || is.op6up )
    {
      if this.sText )
      {
        document.getElementByIdthis.id+"d" ).style.color = color;
        //this.setCaption( this.sText, this.bBold, this.sIcon, this.iIconWidth, this.iIconHeight, this.iconBorder );
      }
    }
  }

}

Xlayer.prototype.setBgColor = functioncolor )
{
  this.sBgcolor = color;

  if is.nn4up )
    this.lyr.document.bgColor = color;
  else if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op6up )
    this.lyr.style.backgroundColor = color;
}

Xlayer.prototype.setSize = functionw, h )
{
  var iOldWidth = this.w; // store old values
  var iOldHeight = this.h;

  this.w = w; // store new values
  this.h = h;

  if is.nn4up )
  {
    if w == "100%" )
      this.lyr.resizeTowindow.innerWidth, h );
    else 
      this.lyr.resizeTow, h );
  }
  else if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op7up )
  {
    if w == "100%" )
    {
      this.lyr.style.width = "100%";
      this.lyr.style.height = h + 'px';
    }
    else
    {
      this.lyr.style.width = w + 'px';
      this.lyr.style.height = h + 'px';
    }

    this.setClippingthis.iClipTop, this.iClipRight + w - iOldWidth ),  this.iClipBottom + h - iOldHeight )this.iClipLeft );

    if is.iewin5up && this.iframe // recreate iframe on resize
      this.setIframethis.src );
  }
  else if is.op6up && !is.op7up )
  {
    if w == "100%" )
    {
      this.lyr.style.pixelWidth = "100%";
      this.lyr.style.pixelHeight = h;
    }
    else
    {
      this.lyr.style.pixelWidth = w;
      this.lyr.style.pixelHeight = h;
    }
  }
}

Xlayer.prototype.setPos = functionx, y, offsetX, offsetY )
{
  var parent;
  if this.parentCoordsOnly )
    parent = this.parentCoordsOnly;
  else
    parent = this.parent;
    
  // calc x, y ---
  if x == "centered" )
    x = XlayerParent.prototype.getXparent XlayerParent.getWparent this.w / 2;
  else if x == "left" )
    x = this.xlayerParent.getXparent );
  else if x == "right" )
    x = XlayerParent.prototype.getXparent + XlayerParent.prototype.getWparent this.w;

  if y == "centered" )
    y = XlayerParent.prototype.getYparent XlayerParent.prototype.getHparent this.h / 2;
  else if y == "top" )
    y = XlayerParent.prototype.getYparent );
  else if y == "bottom" )
    y = XlayerParent.prototype.getYparent + XlayerParent.prototype.getHparent this.h;

  if offsetX )
    x += offsetX;
  if offsetY )
    y += offsetY;

  this.x = x;
  this.y = y;

  // set position ---
  if is.nn4up )
  {
    this.lyr.moveTothis.x, this.y );
  }
  else if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op6up )
  {
    this.lyr.style.top = this.y + "px";
    this.lyr.style.left = this.x + "px";
  }
}

Xlayer.prototype.setVisibility = functionbVisibility 
{
  this.bVisibility = bVisibility;
  if this.lyr 
  {
    if is.nn4up 
    {
      this.lyr.visibility = bVisibility )"show" "hide";
    }
    else if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op6up 
    {
      this.lyr.style.visibility = bVisibility )"visible" "hidden";
    }
  }
}

Xlayer.prototype.isVisible = function() 
{
  return this.bVisibility;
}

Xlayer.prototype.setFontsize = functioniFontsize )
{
  this.iFontsize = iFontsize;
}

Xlayer.prototype.setFontface = functionsFontface )
{
  this.sFontface = sFontface;
}

Xlayer.prototype.setClipping = functiontop, right, bottom, left )
{
  if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op7up )
  {
    this.lyr.style.clip = "rect(" + top + "px " + right + "px " + bottom + "px " + left + "px)";
  }
  else if is.nn4up )
  {
    this.lyr.clip.top = top;
    this.lyr.clip.right = right;
    this.lyr.clip.bottom = bottom;
    this.lyr.clip.left = left;
  }
  this.iClipTop = top;
  this.iClipRight = right;
  this.iClipBottom = bottom;
  this.iClipLeft = left;
}

Xlayer.prototype.setZindex = functioniZindex )
{
  this.iZindex = iZindex;

  if is.iewin5up || is.iemac5up || is.gk || is.sf || is.kq3up || is.op6up )
  {
    this.lyr.style.zIndex = iZindex;
  }
  else if ( <