
Originally Posted by
thewebmacster
I'm having difficulty figuring out how to I specify any url instead of the naming convention? For example say I wanted to have the selection Large & Blue go to dynamicdrive.com or anywhere else?
How do I do that?
Here is where the url is opened:
Code:
function jumptolink(el){
window.open(el.value.toLowerCase().replace(/ /g, '')+'.htm',target);
}
It should first be changed to this:
Code:
function jumptolink(el){
var urlbase=el.value.toLowerCase().replace(/ /g, '');
window.open(urlbase+'.htm',target);
}
This will make it easy to check the urlbase and determine if it is ok to use it or not. If you have just one or two links that you want to go elsewhere, you can do this:
Code:
function jumptolink(el){
var urlbase=el.value.toLowerCase().replace(/ /g, '');
if (urlbase=='smallred')
window.open('http://www.dynamicdrive.com/',target);
else if (urlbase=='largeblue')
window.open('http://www.google.com/',target);
else
window.open(urlbase+'.htm',target);
}
If most or all of your links will use something other than the naming convention, you would probably want to make up an array and loop through it to determine the page to open:
Code:
var urls=[];
urls[0]=["smallred", "http://www.somedomain.com/"];
urls[1]=["smallblue", "http://www.somedomain.com/"];
urls[2]=["smallyellow", "http://www.somedomain.com/"];
urls[3]=["smallgreen", "http://www.somedomain.com/"];
urls[4]=["mediumred", "http://www.somedomain.com/"];
urls[5]=["mediumblue", "http://www.somedomain.com/"];
urls[6]=["mediumyellow", "http://www.somedomain.com/"];
urls[7]=["mediumgreen", "http://www.somedomain.com/"];
urls[8]=["largered", "http://www.somedomain.com/"];
urls[9]=["largeblue", "http://www.somedomain.com/"];
urls[10]=["largeyellow", "http://www.somedomain.com/"];
urls[11]=["largegreen", "http://www.somedomain.com/"];
urls[12]=["extralargered", "http://www.somedomain.com/"];
urls[13]=["extralargeblue", "http://www.somedomain.com/"];
urls[14]=["extralargeyellow", "http://www.somedomain.com/"];
urls[15]=["extralargegreen", "http://www.somedomain.com/"];
urls[16]=["xxlargered", "http://www.somedomain.com/"];
urls[17]=["xxlargeblue", "http://www.somedomain.com/"];
urls[18]=["xxlargeyellow", "http://www.somedomain.com/"];
urls[19]=["xxlargegreen", "http://www.somedomain.com/"];
function jumptolink(el){
var urlbase=el.value.toLowerCase().replace(/ /g, '');
for (var i_tem = 0; i_tem < urls.length; i_tem++)
if (urls[i_tem][0]==urlbase){
window.open(urls[i_tem][1],target);
return;
}
else
window.open(urlbase+'.htm',target);
}
Replace http://www.somedomain.com/ in each array entry with the desired url. If you want some of them to still go to the page that would have been named in the original method, remove the entry from the array but, remember - the numbers must still run in sequence. These numbers:
Code:
urls[2]=["smallyellow", "http://www.somedomain.com/"];
urls[3]=["smallgreen", "http://www.somedomain.com/"];
Bookmarks