Jump to content

Client-side Include


qwerty

Recommended Posts

hello.i'm quite new to html (and javascript), that's why i need your help. i want to use a menu on my web page, and i chose to use includes instead of frames (obviously). i have installed apache on my PC and i enabled server-side includes: it works great.in my index.shtml file i wrote this line:

<table cellspacing="0" id="menu">        <tr>          <td><a href="index.html" class="nav" id="homenav">Home</a></td>        </tr>        <tr>          <td><a href="news.html" class="nav" id="newsnav">News</a></td>        </tr>        <tr>          <td><a href="desc.html" class="nav" id="abnav">About</a></td>        </tr>        <tr>          <td><a href="contact.html" class="nav" id="connav">Contact</a></td>        </tr>      </table>

but the problem is that at my school there is no web server installed, so i am unable to use SSI. that's why i need to use javascript.i tried to do it like this, but it didn't work:i wrote this in the body of my index.html:

document.writeln("<table cellspacing='0' id='menu'>");document.writeln(" <tr>");document.write(" <td>");document.write("<a href='index.html' class='nav' id='homenav'>");document.write("Home");document.write("</a>");document.writeln(" </td>");document.writeln(" </tr>");document.writeln(" <tr>");document.write(" <td>");document.write("<a href='news.html' class='nav' id='newsnav'>");document.write("News");document.write("</a>");document.writeln(" </td>");document.writeln(" </tr>");document.writeln(" <tr>");document.write(" <td>");document.write("<a href='desc.html' class='nav' id='abnav'>");document.write("About");document.write("</a>");document.writeln(" </td>");document.writeln(" </tr>");document.writeln(" <tr>");document.write(" <td>");document.write("<a href='contact.html' class='nav' id='connav'>");document.write("Contact");document.write("</a>");document.writeln(" </td>");document.writeln(" </tr>");document.write("</table>");

please point me in the right direction....thanks

Link to comment
Share on other sites

There is no reason why that code should not work. Just to be sure, I actually ran your set-up (Firefox 3.x) and it does work. The language="Javascript" part should not be there, but that won't cause the problem.There must be a detail you've forgotten to mention.Your script file doesn't have <script> tags in it, does it?

Link to comment
Share on other sites

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

You're missing an equals sign:
<script language="Javascript" src="menu.js" type="text/javascript"></script>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...