help: putting my menubar code in separate file

Discussion in 'JavaScript' started by madmn, Feb 21, 2006.

  1. #1
    I have successfully put most the code associated with my menubar and rollover images in a separate .js file. Here is some code I couldn't figure out how to get into the .js file.

    <body onload="MM_preloadImages('images/home-50grey-dark.gif','images/topban_12-dark.gif','images/topban_14-dark.gif','images/topban_16-dark.gif','images/links-50grey-dark.gif')">

    <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <th width="199" height="109" scope="col"><img src="images/blk-stripes-fade_03.gif" width="199" height="109" /></th>
    <th width="57" scope="col"><img src="images/blk-stripes-fade_04.gif" width="57" height="109" /></th>
    <th background="images/blk-stripes-fade_05.gif" scope="col"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    </th><th width="5" scope="col"><img src="images/blk-stripes-fade_07.gif" width="5" height="109" /></th>
    </tr>
    </table>
    <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <th width="113" scope="col"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image15','','images/home-50grey-dark.gif',1)"><img src="images/home-50grey.gif" name="Image15" width="113" height="28" border="0" id="Image15" /></a></th>
    <th width="1" scope="col"><img src="images/topban_11.gif" width="1" height="28" /></th>
    <th width="175" scope="col"><a href="properties.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image16','','images/topban_12-dark.gif',1)"><img src="images/topban_12.gif" name="Image16" width="175" height="28" border="0" id="Image16" /></a></th>
    <th width="1" scope="col"><img src="images/topban_11.gif" width="1" height="28" /></th>
    <th width="174" scope="col"><a href="about.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image17','','images/topban_14-dark.gif',1)"><img src="images/topban_14.gif" name="Image17" width="174" height="28" border="0" id="Image17" /></a></th>
    <th width="1" scope="col"><img src="images/topban_11.gif" width="1" height="28" /></th>
    <th width="173" scope="col"><a href="contact.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image18','','images/topban_16-dark.gif',1)"><img src="images/topban_16.gif" name="Image18" width="173" height="28" border="0" id="Image18" /></a></th>
    <th width="1" scope="col"><img src="images/topban_11.gif" width="1" height="28" /></th>
    <th scope="col"><a href="links.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image19','','images/links-50grey-dark.gif',1)"><img src="images/links-50grey.gif" name="Image19" width="111" height="28" border="0" id="Image19" /></a></th>
    </tr>
    </table>

     
    madmn, Feb 21, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It is not possible to put html or any non JS code in a JS file.

    You could use a server side include which would allow you to have one header file at the top of your page and then your main content. Then you can alter the header on every page and only change one file.

    eg
    include(header.php3);
    
    echo"Page content";
    
    echo(footer.php3);
    PHP:
    the header.php3 page can then call the external JS file you have made as well as containing the menu code from the top of the page.
     
    mad4, Feb 21, 2006 IP
  3. madmn

    madmn Well-Known Member

    Messages:
    431
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Thanks for the input. Does this file contain anything like Javascript or CSS in it?

    <th width="113" scope="col"><a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image15','','images/home-50grey-dark.gif',1)"><img src="images/home-50grey.gif" name="Image15" width="113" height="28" border="0" id="Image15" /></a></th>
     
    madmn, Feb 21, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    No CSS in the code you posted but onmouseout="MM_swapImgRestore()" is javascript.
     
    mad4, Feb 21, 2006 IP