Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Add more links to Submenu; That is, the bar with search, members...
Topic Started: Jun 23 2009, 04:32 PM (515 Views)
Aeroice
C'est un piège!
[ *  *  * ]
This allows you to add as many links to the submenu as necessary. It does require a bit of setup, but it isn't really hard.

First: you have to decide if you want the link to come before or after the links that are already there (search, members, .... etc.) This isn't really hard to do either. You can chose quite a few options.

So here we go. Here's the code.
Code:
 
<script type='text/javascript'>
// <![CDATA[
var links = [], n = 0;
//start editing here
var before = false;
links[n++] = ['http://www.google.com/','Google','before'];
links[n++] = ['http://www.yahoo.com/','Yahoo'];
links[n++] = ['http://if.invisionfree.com/','Support Board'];
//your ride ends here. :(
//if you do know how to edit this, feel free to, though.
var l = links.length;
while (l--){
var c = document.getElementById('submenu'), urlstr = "<a href='" + links[l][0] + "'>" + links[l][1] + "</a>";
if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after") == -1) c.innerHTML = urlstr + " " + c.innerHTML;
else if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after")!=-1) c.innerHTML += " " + urlstr;
else if (before && !links[l][2]) c.innerHTML = urlstr + " " + c.innerHTML;
else if (links[l][2] && links[l][2].indexOf("before")!=-1) c.innerHTML = urlstr + " " + c.innerHTML;
else c.innerHTML += " " + urlstr;
}
// ]]>
</script>
Okay... looks like a lot, right? It's not THAT bad.

See the part that says
Code:
 
var before = false;
? That's where the setup starts.

Basically... you can chose if you want all links to go before the links or not. If you want them all to go before, change that to
Code:
 
var before = true;
If not, just leave it how it is.

Here comes the adding links part. So here's the basic format:
Code:
 
links[n++] = ['url to link','What you want the link to say','before or after (optional)'];
Be sure not to get your commas and quotation marks mixed up - this is coding, not grammar, so the comma will go after the quotation mark most of the time.

You can add more or less of these links as needed. Here's another example:
Spoiler: click to toggle

If there are any questions setting it up, feel free to post in this topic or PM me on this or any board you may find me on.

And, another example, just for you guys.
Spoiler: click to toggle


Good luck!
Offline Profile Quote Post Goto Top
 
Viral.
Member Avatar
Member
[ *  *  *  *  *  * ]
I made this last year - and it's a lot shorter than that:
Code:
 
<script type="text/javascript">
//<![CDATA[
function submenu(l,t,p){var l = '<a href="'+l+'">'+t+'</a>';
if(p=="before"){$("#submenu").prepend(l);}else{$("#submenu").append(l);}}
submenu("http://google.com","Google","before");
submenu("http://yahoo.com","Yahoo","after");
//]]>
</script>
Offline Profile Quote Post Goto Top
 
Aeroice
C'est un piège!
[ *  *  * ]
Viral.
Jun 23 2009, 05:04 PM
I made this last year - and it's a lot shorter than that:
Code:
 
<script type="text/javascript">
//<![CDATA[
function submenu(l,t,p){var l = '<a href="'+l+'">'+t+'</a>';
if(p=="before"){$("#submenu").prepend(l);}else{$("#submenu").append(l);}}
submenu("http://google.com","Google","before");
submenu("http://yahoo.com","Yahoo","after");
//]]>
</script>
I guess. Mine didn't force you to have 'before' or 'after' though, and it also gave the option to have them all before or all after.
Offline Profile Quote Post Goto Top
 
gamer3
Member Avatar
Member
[ *  * ]
May i ask where these codes go?
Offline Profile Quote Post Goto Top
 
Aeroice
C'est un piège!
[ *  *  * ]
Below the board / above the copyright.
Offline Profile Quote Post Goto Top
 
mariobros
Member
[ * ]
just what ive been looking for
Offline Profile Quote Post Goto Top
 
d0wn10ad
Member Avatar
Member
[ *  * ]
Thanks for this code! Just what I've been looking for.
Edited by d0wn10ad, Jul 18 2009, 07:23 PM.
Offline Profile Quote Post Goto Top
 
ju5t_bl4z3
Member Avatar
Member
[ * ]
This is exactly what I was looking for. Too bad it doesn't work though :(
Offline Profile Quote Post Goto Top
 
Aeroice
C'est un piège!
[ *  *  * ]
ju5t_bl4z3
Oct 25 2009, 02:27 PM
This is exactly what I was looking for. Too bad it doesn't work though :(
Can I see your code setup? :)
Offline Profile Quote Post Goto Top
 
ju5t_bl4z3
Member Avatar
Member
[ * ]
Code:
 
<script type='text/javascript'>// <![CDATA[var links = [], n = 0;//start editing herevar before = false;links[n++] = ['http://www.google.com/','Google','before'];links[n++] = ['http://www.yahoo.com/','Yahoo'];links[n++] = ['http://if.invisionfree.com/','Support Board'];//your ride ends here. :(//if you do know how to edit this, feel free to, though. var l = links.length;while (l--){var c = document.getElementById('submenu'), urlstr = "<a href='" + links[l][0] + "'>" + links[l][1] + "</a>";if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after") == -1) c.innerHTML = urlstr + " " + c.innerHTML;else if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after")!=-1) c.innerHTML += " " + urlstr;else if (before && !links[l][2]) c.innerHTML = urlstr + " " + c.innerHTML;else if (links[l][2] && links[l][2].indexOf("before")!=-1) c.innerHTML = urlstr + " " + c.innerHTML;else c.innerHTML += " " + urlstr;}// ]]></script>
Offline Profile Quote Post Goto Top
 
Aeroice
C'est un piège!
[ *  *  * ]
It's because you've compressed it.. unfortunately, that isn't going to do so well. In order to get it to work you'll have to have it all spread out like in the original code. :)

Or you can try this:
Code:
 
<script type='text/javascript'>/*<![CDATA[*/var links = [], n = 0;/*start editing here*/var before = false;links[n++] = ['http://www.google.com/','Google','before'];links[n++] = ['http://www.yahoo.com/','Yahoo'];links[n++] = ['http://if.invisionfree.com/','Support Board'];/*your ride ends here. :(if you do know how to edit this, feel free to, though.*/var l = links.length;while (l--){var c = document.getElementById('submenu'), urlstr = "<a href='" + links[l][0] + "'>" + links[l][1] + "</a>";if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after") == -1) c.innerHTML = urlstr + " " + c.innerHTML;else if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after")!=-1) c.innerHTML += " " + urlstr;else if (before && !links[l][2]) c.innerHTML = urlstr + " " + c.innerHTML;else if (links[l][2] && links[l][2].indexOf("before")!=-1) c.innerHTML = urlstr + " " + c.innerHTML;else c.innerHTML += " " + urlstr;}/* ]]> */</script>
Edited by Aeroice, Oct 26 2009, 06:26 PM.
Offline Profile Quote Post Goto Top
 
ju5t_bl4z3
Member Avatar
Member
[ * ]
I wasnt compressing it, when I copied and pasted it, it came out like that. I did seperate it though like how it was displayed but it didnt work.

But this new version here works perfectly :D ~ thanks
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code & Modification Database · Next Topic »
Add Reply