/    Sign up×
Community /Pin to ProfileBookmark

Multi Page Navigation

I found a javascript that I would like to use but cannot get it to work. I am totally new at javascript and would appreciate anyone pointing out what I am doing wrong.

Thanks!

Here is my home page coding:

<html>
<head>
<title>Southgate Community School District</title>
</head>
<body>
<table width=”100%” cols=”2″ border=”1″>
<tr>
<td width=”30%”>
<script language=”javascript” src=”terrynavbar.js”>
</script>
</td>
<td width=”70%”>

<h1>Welcome to the Southgate Community School District Website</h1>
</td>
</tr>
</table>
</body>
</html>

Here is my js file coding”

<html>
<head>
<SCRIPT LANGUAGE=JavaScript>
document.write(“<a href=’activities.htm’>Activities</a><br>”)
document.write(“<a href=’contactus.htm’>Contact Us</a><br>”)
document.write(“<a href=’departments.htm’>Departments</a><br>”)
document.write(“<a href=’district.htm’>District Info</a><br>”)
document.write(“<a href=’schools.htm’>Schools</a><br>”)
</SCRIPT>
</head>
<body>
Menu
</body>
</html>

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@JPnycAug 19.2004 — Is that 2 pages? Because you have 2 sets of html, head, and body tags. You can only have 1 set per page. Can you tell me why you want to dynamically write 5 links instead of just coding them to the page in HTML? You cannot generate only part of a page using document.write. If you use that to write the page, it must write the WHOLE page, unless you're using frames.
Copy linkTweet thisAlerts:
@thereseauthorAug 19.2004 — Yes, it is two files. I did not explain very well what I was trying to do. The reason I want the menu to read from another file is because I developed and update a website www.southgateschools.com which has gotten to have a lot of pages. The school district likes to change things every now and then including the menu on the left. Well, as you can imagine, changing the menu on 100+ pages is not fun. I do this as a side job, so I try to incorporate any time saving features I can. In my post, I put in only some of the links I want to include, and I expect to be making the menu much larger in the near future. That is why I would like to be able to change only one file, instead of all pages on the site.

I had gotten this idea from browsing the web and the sample code they gave didn't really tell me how to code the js file, so that is where I imagine my problem lies. I am not using frames. I tried that and was voted down. Are you saying that I cannot write my menu this way?

Thank you

Therese
Copy linkTweet thisAlerts:
@JPnycAug 19.2004 — Correct, you cannot generate only part of a file using document.write statements. You have to either have it write the whole page, or none. But in order to solve your problem, you could use frames. Have either a top frame or a side frame with the links, then just change the main frame to the other pages. In that way, you'd have only 1 file to add links to. Here's an example of an HTML doc which will just cover the top of a site I did. All it contains is the links and header. It will look bare if you load it because the css file is remoted:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html><head>

<title>Gabriel & Katsarelis</title>

<link rel="stylesheet" type="text/css" href="jk.css"/>

</head>

<body>

<center><strong><span class="header" id="head">GABRIEL&nbsp;&&nbsp;KATSARELIS&nbsp;ARCHITECTS,&nbsp;LLC.</span><br/>

<span class="subhead"id="subhead">ARCHITECTURE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PLANNING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRAINING</span></strong></center>

<table class="buttons" cellspacing="0" cellpadding="0" height="3.3%" width="102.5%">

<tr>

<td class="marble">

<a href="index.htm" target="_top">&nbsp;&nbsp;Home&nbsp;&nbsp;</a></td>

<td class="marble">

<a href="aboutus1.htm"target="bottom">&nbsp;&nbsp;Profile&nbsp;&nbsp;</a></td>

<td class="marble">

<a href="photo21.htm"target="bottom">&nbsp;&nbsp;Photos&nbsp;&nbsp;</a></td>

<td class="marble">

<a href="history1.htm"target="bottom">&nbsp;&nbsp;History&nbsp;&nbsp;</a></td>

<td class="marble"><a href="contact1.htm"target="bottom">&nbsp;Autocad Training&nbsp;</a></td>

<td class="marble">

<a href="clients1.htm" target="bottom">&nbsp;&nbsp;Clients&nbsp;&nbsp;</a></td>

<td class="marble"><a href="contact1.htm"target="bottom">&nbsp;&nbsp;Contact Us&nbsp;&nbsp;</a></td></tr></table>

</body></html>
Copy linkTweet thisAlerts:
@JPnycAug 19.2004 — Now here is the frame window that the previous file takes up the top portion of:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<html><head>

<title>Gabriel & Katsarelis</title>

</head>

<frameset rows="21%,79%" frameborder="0" framespacing="0" border="0">

<frame name="top" src="jk.htm" frameborder="0" framespacing="0" border="0" scrolling="no"noresize="noresize" />
<frame name="bottom"src="aboutus1.htm" frameborder="0"framespacing="0" border="0"noresize="noresize" />

</frameset>

</html>

Basically a frame is a way to display more than 1 HTML doc at a time, in a web browser. Here's a tutorial: http://www.w3schools.com/html/html_frames.asp
Copy linkTweet thisAlerts:
@thereseauthorAug 19.2004 — Thank you for the link to the Frames tutorial. I will definitely be visiting it. I did have a menu in a frame for awhile, but had a few problems with it. I did the work in Front Page and found it to be not very easy to work with later on, specifically, everytime I made a change in the menu, I had to re-upload every page (I do my work from home and ftp everything). I wanted to learn how to do frames without using Front Page. Also, the IT people at the district said they didn't like frames, but never gave me any reason why.

Well anyway, thanks for the advice, I really appreciate it.

Therese
Copy linkTweet thisAlerts:
@JPnycAug 19.2004 — There are methods by which you could generate the menu with javascript, but they're a good deal more complex than what you have there, and not really adivsable. Tell whomever is in charge that frames are less of a problem than a JS generated menu is. Lots of people now surf with JS disabled (like me) and if they don't have a JS enabled browser, they'll have no way of navigating your site. Contrarily all browsers support frames (within reason) and it's not something the use can turn off, like they can JS.
Copy linkTweet thisAlerts:
@VladdyAug 19.2004 — Neither frames :rolleyes: nor JS :rolleyes: are a solution, SSI is.
×

Success!

Help @therese spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...