[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/24/2000 at 06:45AM PDT, ID: 11644058
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Popup Menu In Netscape

Asked by mcrider in JavaScript

Tags: javascript, popup, div, menu, netscape

This is driving me crazy! The following code works PERFECTLY in IE, however, I can not get the stuff to work properly in Netscape.

Basically what is happening is when you hover over the javascript menus in IE the menu pops up on top of the textbox (like it should!) however, in Netscape, the menu appears *BEHIND* the textbox.

Here is the HTML document:

------------------------------------------------------------------------------------------------------------------------
<HTML><HEAD><TITLE>Test Menu</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="mpopup.js"></SCRIPT>
<BR><BR>
<FORM>
<INPUT TYPE=TEXT NAME=TEST1 SIZE=60 MAXLENGTH=60 VALUE="">
</FORM>
</BODY>
</HTML>
------------------------------------------------------------------------------------------------------------------------



and here is the JavaScript "mpopup.js"

------------------------------------------------------------------------------------------------------------------------
//do browser detect stuff
var NS4 = (document.layers) ? true : false;
var IE4 = (document.all) ? true : false;
var layerRef = (NS4) ? "document" : "document.all";
var styleRef = (NS4) ? "" : ".style";

var menu_items=new Array("menu1","menu2");
var activeMenu = 0;
var maxZ = 1;
var prev_menu_item=null;

// Popup Class that has all the methods and properties
function popout(id, posY, posX, width) {
  this.id = id;       // the element's name (and the variable's name)
  this.posY = posY;   // the element's top property
  this.posX = posX;   // the element's left property
  this.width = width; // the element's width
  this.show = false;  // do not show the element
  this.makeMenuBar = makeMenuBar;  // constructs the image's tab
  this.makeMenu = makeMenu;        // constructs the drop down box
  this.showMenu = showMenu;        // sets the element's visibility
  this.hideMenu = hideMenu;        // hides the drop down box
}

// Stylesheet to set properties for the individual Menu Items
function setMenuItemStyle(){
  document.write(
    '\n<STYLE TYPE="text/css">',
    '.menubar {',
    'color : blue;',
    'font-family: \"arial\";',
    'font-size : 12px;',
    'font-weight : bold;',
    'text-decoration : none;',
    '}\n',
    'A.menubar:hover {color: red;}\n\n',
    '.link {',
    'color : white;',
    'font-family: \"arial\";',
    'font-weight : bold;',
    'font-size : 12px;',
    'text-decoration : none;',
    '}\n\n',
    'A.link:hover {color: red;}\n\n',
    'A.link:active {',
    'color : red;',
    'text-decoration : none;',
    '}\n</STYLE>\n'
  );
}

// Create the top level Menu Bar
function makeMenuBar(imgURL, imgHeight, imgWidth, imgAlt) {
  document.write(
    '\n<STYLE TYPE="text/css">',
    '#', this.id, 'img {',
      'position: absolute;',
      'font-family: \"arial\";',
      'font-size : 12px;',
      'left: ',this.posX, '; top: ', this.posY, ';',
      'width: ', imgWidth, ';',
      'text-decoration : none;',
      'z-index: 1',
    '}',
    '</STYLE>',  
    '\n<DIV ID="', this.id, 'img">',
    '\n<A href="javascript:', this.id, '.showMenu('+imgAlt+')" '+
    'onmouseover="javascript:', this.id, '.showMenu('+imgAlt+')" '+
    'onclick="if (window.focus) {window.focus(); return false;}" class="menubar">' + imgURL+
    '</A>\n</DIV>'
  );
}

// Creates the drop down box, sets its properties & ..
// .. displays the individual links.
function makeMenu(boxBg, boxColor, boxCode) {
  var padding = (NS4) ? '' : 'padding: 3 0 3 3;';
  document.write(
    '\n<STYLE TYPE="text/css">',
    '#', this.id, 'box {',
      'position: absolute;',
      'left: ',this.posX, '; top: ', (this.posY+15), ';',
      'width: ', this.width, ';',
      'height: auto;',
      'layer-background-color: ', boxBg, ';',
      'background-color: ', boxBg, ';',
      'visibility: hidden;',
      'border-width: 2px;',
      'border-style: solid;',
      'border-color: ', boxColor, ';',
      padding,
      'z-index: 1',
    '}',
    '</STYLE>',
    '\n<DIV ID="', this.id, 'box" onMouseOver="javascript:{if (!NS4) window.event.cancelBubble = true;}">',
    boxCode,
    '</DIV>\n'
  );
//
}

function showMenu(URL) {
  // First hide ALL the drop down boxes
  for (var i=0;i<menu_items.length;i++){
    eval(menu_items[i]+".show = false");
    eval(layerRef + '["' + menu_items[i] + 'box"]' + styleRef + '.visibility = "hidden"');
  }// End of for

  // Display the clicked link in a frame
  // eval(window.parent.frames[1].location.replace(URL));
  if (NS4) {
    eval('document.' + this.id + 'img.left = ' + this.posX);
    eval('document.' + this.id + 'img.zIndex = ' + (++maxZ));
    //eval('document.' + this.id + 'box.zIndex = ' + maxZ);
    eval('document.' + this.id + 'box.zIndex = 50');
    eval('document.' + this.id + 'box.visibility = "show"');
  } else {
    eval(this.id + 'img.style.left = ' + this.posX);
    eval(this.id + 'img.style.zIndex = ' + (++maxZ));
    eval(this.id + 'box.style.zIndex = ' + maxZ);
    eval(this.id + 'box.style.visibility = "visible"');
  }
  activeMenu = this.id;     // set the name of the currently active menu

  // For IE Browsers catch the onMouseOver event at the menu &..
  // .. do not let it get to the document.
  if (styleEnabled() && !NS4) window.event.cancelBubble = true;
}

// Hides the currently active menu
function hideMenu(e){
  //check if theres a menu active
  if (activeMenu) {
    menuID = activeMenu+ "box";
    if (NS4) {
      menuX1 = document[menuID].left;
      menuX2 = menuX1 + document[menuID].clip.right;
      menuY1 = document[menuID].top;
      menuY2 = menuY1 + document[menuID].clip.bottom;
   
      if (e.pageX < menuX1 || e.pageX > menuX2 || e.pageY > menuY2) {
        eval(layerRef + '["' + menuID + '"]' + styleRef + '.visibility = "hidden"');
        activeMenu = 0;
      }
    }else{
       eval(layerRef + '["' + menuID + '"]' + styleRef + '.visibility = "hidden"');
      activeMenu = 0;
    }
  }  
}

// Check if Stylesheets are enabled or not
function styleEnabled(){
  return ((NS4) || IE4);
}

function init(){
  if (!styleEnabled()) return;

  // Trap the onMouseMove event and call hideMenu
  if (NS4){
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = hideMenu;
  }else{
    document.onmouseover = hideMenu;
  }

  setMenuItemStyle(); // set the default display style for the menu items
  activeMenu = 0;     // Initially no menu is active
  var spacing=0;
  var image_width=0;

  // Create the 1st Popup menu (For Corporate Information)
  if (NS4){
    spacing=200;
    image_width=138;
    menu1 = new popout('menu1', 13,spacing, 200);
  }else{
    spacing=220;
    image_width=145;
    menu1 = new popout('menu1', 5,spacing, 200);
  }

  // Insert the URL to the images you want here
  // with the ID, Y position, X Position & size/width of the box
  menu1.makeMenuBar('Menu_1', 25, image_width, "\'corp_info.html\'");
  menu1.makeMenu('black', 'gray',
    '\n<A href="corp_info_1.html" target="_self" class="link">MENU1 ITEM 1</A>\n<BR>' +
    '\n<A href="corp_info_2.html" target="_self" class="link">MENU1 ITEM 2</A>\n<BR>' +
    '\n<A href="corp_info_3.html" target="_self" class="link">MENU1 ITEM 3</A>\n<BR>' +
    '\n<A href="corp_info_4.html" target="_self" class="link">MENU1 ITEM 4</A>\n<BR>' +
    '\n<A href="corp_info_5.html" target="_self" class="link">MENU1 ITEM 5</A>\n<BR>' +
    '\n<A href="corp_info_6.html" target="_self" class="link">MENU1 ITEM 6</A>\n<BR>');


  // Create the 2nd Popup menu
  // with the ID, Y position, X Position & size/width of the box
  if (NS4){
    spacing+=image_width+5;
    image_width=65;
    menu2 = new popout('menu2', 13,spacing ,205);
  }else{
    spacing+=image_width+5;
    image_width=70;
    menu2 = new popout('menu2', 5,spacing ,205);
  }

  // Insert the URL to the images you want here
  menu2.makeMenuBar('Menu_2', 25, image_width, "\'products.html\'");
  menu2.makeMenu('black', 'gray',
    '\n<A href="products_1.html" target="_self" class="link">MENU2 ITEM 1</A>\n<BR>' +
'\n<A href="products_2.html" target="_self" class="link">MENU2 ITEM 2</A>\n<BR>' +
    '\n<A href="products_3.html" target="_self" class="link">MENU2 ITEM 3</A>\n<BR>' +
    '\n<A href="products_4.html" target="_self" class="link">MENU2 ITEM 4</A>\n<BR>' +
    '\n<A href="products_5.html" target="_self" class="link">MENU2 ITEM 5</A>\n<BR>' +
    '\n<A href="products_6.html" target="_self" class="link">MENU2 ITEM 6</A>\n<BR>');

}

init();

------------------------------------------------------------------------------------------------------------------------



Cheers!®©

[+][-]10/24/00 07:19 AM, ID: 4880940

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/24/00 07:28 AM, ID: 4881140

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/26/00 01:53 PM, ID: 4930661

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/00 01:39 AM, ID: 5118682

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/00 02:16 AM, ID: 5119225

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/00 05:09 AM, ID: 5122460

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/00 05:18 AM, ID: 5122642

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: javascript, popup, div, menu, netscape
Sign Up Now!
Solution Provided By: CJ_S
Participating Experts: 6
Solution Grade: A
 
 
[+][-]04/27/02 02:51 PM, ID: 6973952

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/20/02 03:34 PM, ID: 7022617

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/20/02 05:43 PM, ID: 7022873

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91