This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 13th, 2011  |  syntax: None  |  size: 1.43 KB  |  views: 1,568  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.    New Perspectives on JavaScript, 2nd Edition
  3.    Tutorial 4
  4.    Case Problem 1
  5.  
  6.    Author:  Trent Herrring  
  7.    Date:    03-05-2011  
  8.  
  9.    Filename:  jemenus.js
  10.  
  11.    -------------------------------------------------------------
  12.    Function List:
  13.    setTabs()
  14.       Initializes the contents of the printer.htm Web page, locating
  15.       the tab menus and assigning event handler to the tabs.
  16.  
  17.    showTab()
  18.       Shows the currently-select tab menu, bring it to the top
  19.       of the stack
  20.  
  21.  
  22.    -------------------------------------------------------------
  23.    Global Variable List:
  24.  
  25.    currentTab
  26.       An object variable pointing to the currently selected tab
  27.    
  28.    maxZ
  29.       A variable containing maximum z-index value among the tab lists
  30.  
  31.    -------------------------------------------------------------
  32. */
  33.  
  34. var currentTab = null;
  35. var maxZ = 1;
  36.  
  37.  
  38.  
  39. function showTab() {
  40.    currentTab.style.backgroundColor = "#FFFFFF";
  41.    maxZ++;
  42.    tabList = this.getElementsByTagName("ul")[0];
  43.    tabList.style.zIndex = maxZ;
  44.    currentTab = this;
  45.    currentTab.style.backgroundColor = "rgb(221, 221, 255)";
  46. }
  47.  
  48. function setTabs() {
  49. var menuTabs = new Array();
  50. var allElems = document.getElementsByTagName("*")
  51. for(var i = 0; i < allElems.length; i++){
  52. if(allElems.className == 'tab'){
  53. menuTabs.push(allElems[i]);
  54. }
  55. }
  56. currentTab = menuTabs[0];
  57. for(var a = 0; a < menuTabs.length; a++){
  58. menuTabs[a].onclick = showTab;
  59. }
  60.  
  61. }
clone this paste RAW Paste Data