Advertisement
Guest User

Untitled

a guest
Mar 13th, 2011
1,836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement