|
Post by Wormopolis on Nov 27, 2010 3:50:46 GMT -8
Browser Tested: IE and FF placement: global header (very top)
Short code that lets you insert in a new button anywhere in the existing menubar based on placement. Which means if you want your button to be second, you can make it second. you can make it first, you can make it last. whatever. also allows you to create an image button or text button.
code:
<script type="text/javascript"> <!-- // add buttons in menu with placement // by Wormopolis - www.wormocodes.com // version 1.41
var buttonSeperate=" | ";
function addButtonToMenu(spot, type, data, url, restr) { if (pb_username=='Guest' && restr) return; for (lnks=document.getElementsByTagName('a'), lk=0; lk<lnks.length; lk++) { if (lnks[lk].href.match(/action=search/)) break; } var mbar=lnks[lk].parentNode; var currentMenuButtons=mbar.getElementsByTagName('a'); var nwbtn=document.createElement('a'); nwbtn.href=url; switch(type) { case 0: //type=image btnimg=document.createElement('img'); btnimg.src=data; btnimg.border='0'; nwbtn.appendChild(btnimg); break; case 1: //type=text btntxt=document.createTextNode(data); nwbtn.appendChild(btntxt); break; default: return null; } var spotbtn=(spot>0 ? currentMenuButtons[spot] : mbar.lastChild); if (spot==-1) mbar.insertBefore(document.createTextNode(buttonSeperate), spotbtn); mbar.insertBefore(nwbtn, spotbtn); if (spot!=-1) mbar.insertBefore(document.createTextNode(buttonSeperate), spotbtn); }
// edit code by adding functions here: // addButtonToMenu(spot, type, data, url); // spot = placement in menubar, 0 is first button, -1 to force last // type = button type, 0=image, 1=text // data=image url if type=image, text if type=text // url=location button leads to when clicked // restr=set true to hide from guests, leave blank if guest ok
addButtonToMenu(3, 1, "[ yahoo ]", "http://www.yahoo.com"); addButtonToMenu(1, 0, "http://i197.photobucket.com/albums/aa250/WORMOPOLIS/yahoo_logo.jpg", "http://www.yahoo.com", true); addButtonToMenu(-1, 1, "[ google ]", "http://www.google.com"); // --> </script>
|
|
|
Post by Wormopolis on Nov 3, 2011 18:31:57 GMT -8
version update 1.2: added in switch for hiding new menuitems from Guests
|
|
|
Post by Wormopolis on Jun 21, 2012 18:48:54 GMT -8
version update 1.4: added in a buttonSeperate option
|
|
|
Post by Wormopolis on Jul 3, 2012 13:50:28 GMT -8
version update 1.41: changed seperator behavior
|
|