[thelist] JavaScript help please

Todd Richards todd at promisingsites.com
Fri Jul 1 10:34:49 CDT 2005


Happy Friday!

I want to be able to have a different icon next to my menu links when you
are on that page.  I have a script that I modified, but it is not working.
I had to modify the output for document.write to include my rollovers, and I
have a feeling that is where my problem is.  Escaping quotes, etc. tend to
trip me up.

The original script included a "links_url" but I opted not to use that and
just used the "links" variable with the page extension (.asp) behind it,
hoping to keep it simpler (or not).

The original script said to insert <script language="javascript"
src="/includes/inc_nav.js"></script> where you need the menu to appear,
which is what I did.  However, when I load the page I get no error, and no
menu.  When I do a view source the call to the script (above) is there, but
nothing in terms of menu or images.

If anyone has any thoughts, or a better script to use, I would be forever
grateful.

Thanks,

Todd


****************************************************************************
***************************************


/* The link details */
var links = new Array ("page", "page2", "page3"); 
var links_alt = new Array ("Return to Home", "Go to Page 2", "Go to Page
3"); 
var links_url = new Array ("home.asp", "page2.asp", "page3.asp");

/* Resolve the location */
var loc=String(this.location);
loc=loc.split("/");
loc=loc[loc.length-1].split(".");
loc=loc[loc.length-2];

/* Menu generating function */
function dyn_menu_gen()
{
for(var i=0; i<links.length; i++)
{
 if(loc==links[i])
{
	document.write('<img src="/images/menu_checked.gif" width="17"
height="15" border="0" />
				   <a href="/' + links[i] + '.asp" 
				   onmouseout="MM_swapImgRestore()" 
				   onmouseover="MM_swapImage(\'' + links[i]
+ '\',\'\',\'/images/' + links[i] + '_on.gif\',1)">
				   <img src="/images/' + links[i] +
'_off.gif" alt="' + links_alt[i] + '" name="'
				   + links[i] + '" width="113" height="15"
border="0" id="' + links[i] + '" /></a>');  }  else  {
	document.write('<img src="/images/menu_box.gif" width="17"
height="15" border="0" />
				   <a href="/' + links[i] + '.asp" 
				   onmouseout="MM_swapImgRestore()" 
				   onmouseover="MM_swapImage(\'' + links[i]
+ '\',\'\',\'/images/' + links[i] + '_on.gif\',1)">
				   <img src="/images/' + links[i] +
'_off.gif" alt="' + links_alt[i] + '" name="'
				   + links[i] + '" width="113" height="15"
border="0" id="' + links[i] + '" /></a>');  }  <br> } }
/* Generate the menu */
dyn_menu_gen();







More information about the thelist mailing list