...

View Full Version : Javascript menu problem



barrykap
09-21-2011, 03:22 PM
Hi

Only a very simple beginner (thicko) so please don't laugh :-)

I have a very basic allwebco website and in the root I have menu.js which puts a small menu on the top right of every webpage that calls it.

The index.html page in the root calls this menu.js and also another page in a folder from the root calls it (I prefix menu.js in this page with '../' so as to step back to the root). Also on this sub-page I call another page which is in the same folder. This also calls up 'menu.js' and again I prefix it '../' in order to access it from the root, which is the preceding folder.

However, on this second page, it does not display the menu.

I have tried everything by prefixing it with '/', './', '../' and just leaving it as 'menu.js' but it will not find it.

I suppose it is because it is a 'recursive' situation. ie keeps calling itself over and over? Can anyone help please?

Thanks.

Barry

DanInMa
09-21-2011, 03:27 PM
please show the actual code being used.

barrykap
09-21-2011, 04:57 PM
Hi

Relative code in index.html;-

<script language="JavaScript" type="text/javascript" src="menu.js"></script>

--------------------------------------------------------------------------

code in the lower level pages (in a subfolder from root);

<script language="JavaScript" type="text/javascript" src="../menu.js"></script>


--------------------------------------------------------------------------

code of menu.js;-

var menuheight ="228" // OVERALL MENU HEIGHT
var menuwidth ="140" // OVERALL MENU WIDTH
var botmline ="49" // HEIGHT OF VERT LINE UNDER MENU



document.write('<TABLE cellpadding="0" cellspacing="0" border="0" class="printhide"><tr><td>');
document.write('<img src="picts/spacer.gif" HEIGHT="'+menuheight+'" WIDTH="10"><br>');
document.write('</td><td valign="bottom" align="left">');
document.write('<TABLE cellpadding="0" cellspacing="0" border="0"><tr><td>');
document.write('<img src="picts/spacer.gif" HEIGHT="1" WIDTH="10"><br>');


// START MENU LINKS

// NOTE: COPY AND PASTE THE NEXT 2 LINES TO MAKE A NEW LINK



document.write('</td></tr><tr><td class="menu">');
document.write('<a href="index.html">Home</a><br>');


document.write('</td></tr><tr><td class="menu">');
document.write('<a href="walks.htm">Walks</a><br>');


document.write('</td></tr><tr><td class="menu">');
document.write('<a href="holidays.htm">Holidays</a><br>');


document.write('</td></tr><tr><td class="menu">');
document.write('<a href="footpaths.htm">Footpaths</a><br>');


document.write('</td></tr><tr><td class="menu">');
document.write('<a href="news.htm">News</a><br>');


document.write('</td></tr><tr><td class="menu">');
document.write('<a href="contact.htm">Contact</a><br>');





document.write('</td></tr><tr><td>');
document.write('<img src="picts/menu_bottom.gif" HEIGHT="1" WIDTH="109"><br>');
document.write('</td></tr><tr><td class="menu-line">');
document.write('<img src="picts/spacer.gif" height="'+botmline+'" width="'+menuwidth+'"><br>');
document.write('</td></tr></table>');
document.write('</td></tr></table>');



Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum