Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript menu problem

    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

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    please show the actual code being used.

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •