Wiiplay123

Javascript Menu API

Jun 13th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.97 KB | None | 0 0
  1. // Wiiplay123's Javascript Menu API
  2. // Usage: makeMenu(menu name, image link, image when mouse not over, image when mouse over);
  3. // Menu name is not repeated for each image.
  4. // Image link, image when mouse not over, and image when mouse over repeat.
  5. document.write("<script type=\"text/javascript\" src=\"./jquery.js\"></script>");
  6. var buttons = new Array();
  7. function makeMenu(menuname) {
  8.     document.write("<table>");
  9.     for (var i = 1; i < arguments.length; i = i + 3) {
  10.         document.write("<tr><td><a href=\"" + arguments[i] + "\"><img id=\"" + menuname + String(i) + "\" src=\"" + arguments[i + 1] + "\"></img></a></td></tr>");
  11.         button = menuname + String(i)
  12.         $("#" + menuname + String(i)).mouseover(function(){
  13.             this.src = buttons[this.id][2];
  14.         });
  15.         $("#" + menuname + String(i)).mouseout(function(){
  16.             this.src = buttons[this.id][1];
  17.         });
  18.         buttons[menuname + String(i)] = new Array(menuname, arguments[i + 1], arguments[i + 2]);
  19.     }
  20.     document.write("</table>");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment