Click to See Complete Forum and Search --> : Make Cascading Menu appears on every page


bondie
12-09-2002, 07:54 PM
Hi!

How do I make my cascading menu (written in javascript) appear on every page without using frames?

Please advise.

Thanks!

Beach Bum
12-09-2002, 08:08 PM
why not use frames? but if you don't want to . . .

the only thing i can think of to help would be to ensure that you have the js in an external file so you only need to put the calling statement in each page. that will make it a lot easier to maintain.

to do that put the js in a text file with .js

then put this where you want it in your pages:

<script type="text/javascript" src="xxxxx.js"></script>

bondie
12-09-2002, 08:50 PM
Well.. I think frames are a lot easier too but some options on my cascading menu will be overlapped by the bottom frame (please see my posting http://forums.webdeveloper.com/showthread.php?s=&threadid=739). What do you suggest now?

Thanks.

Beach Bum
12-09-2002, 09:04 PM
now i understand.

i would use an external file as i suggested earlier.

bondie
12-09-2002, 09:19 PM
Hi..

Thanks for your suggestion. As I'm a newbie in js, can you please advise me where to put the statement <script type="text/javascript" src="xxxxx.js"></script>?

Thanks...

Beach Bum
12-09-2002, 10:28 PM
you would put it in the body where you want the script to execute. so if the js is a menu that you want at the top of the page you would put it there.

unless in the js you have specified absolute positioning for your menu, then it would make no difference where you put it.

so it depends on what is in the js.

from a technical perspective, it does not matter. just depends on what is in the script and where you want it.

try it out and see what you get.

and if you are really new . . . don't forget to replace xxxxx with the name of YOUR js file.

bondie
12-10-2002, 12:50 AM
Yes, I have changed XXXX.js to my filename. I am using FrontPage 2000 and added the statement in. However, nothing appears when I preview it. This is the html code:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<script type="text/javascript" src="CascadingMenu.js"></script>
</body>

</html>

Thanks again! :)

hfraser
12-10-2002, 12:56 AM
simplify your life use a server side include! thats what i would do!

that way you can link 20 different menus if you want to and you wont have to recode them in js you can use pure html or what ever!

my 2 cents!

hfraser
12-10-2002, 01:00 AM
oops forgot to tell you a server side include goes like this

<!--#include file="yourfile.html" -->

you can include it anywhere you want!

(you probably will have to change your extension to .shtml instead of .html so the server can process the file!)

bondie
12-10-2002, 01:01 AM
geee... you have tell me in layman's terms.. what is server side include? I am using FrontPage 2000 and most of the stuff is GUI.. thanks!

hfraser
12-10-2002, 01:19 AM
a server side include is probably the simplest action you can put on a page
when you have lets say

<!--#include file="yourfile.html" -->

in your html page right before the server sends the page to the browser it
replaces <!--#include file="yourfile.html" --> with the content of yourfile.html

to work on most server you have to change the .html extension of the file that calls up the serverside include to .shtml

and voila the page you called as now the other page in it as part of it you can
build whole documents like this .

just be sure that the page you call is not a full html doc with

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

</body>
</html>


you can put anything in that file javascript html whatever just dont forget that for the user it will be an integral part of the document!

bondie
12-13-2002, 02:23 AM
To make things easier, I think I would still to call an external .js file. However, I can't get this to work.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<script type="text/javascript" src="CascadingMenu.js"></script>
</body>

</html>


Can someone please advise? :(

ozzga
12-13-2002, 10:52 AM
i usually put that in the head. dunno if it makes a difference though. what is the content of your script?

Beach Bum
12-14-2002, 09:21 AM
bondie -

what you have posted above is correct. and yes, you put it in the body statement where ever you want it to execute. you can also put it in the head, and it will execute before anything in the body - really the same as putting it forst in the body.

so i suspect your problem is what you have in the js file. do not put the <script> </script> tags in the js file, only the code you want to execute.

if you have a complicated js file, try making an easy one to test this first and make sure you have it right. if you need help with your js file, post it.

bondie
12-15-2002, 07:33 PM
Hi guys,

Thanks for your help. Here's the said script. I have changed the file extension from .js to .txt for the purpose of uploading this file.

Many thanks!

Beach Bum
12-16-2002, 06:26 PM
what you posted was a complete html document not a script.

take out everything up to and including the <script> tag.

and take out everything starting from the </script> tag to the end.

you just want the javascript code in the js file.

swon
12-16-2002, 07:05 PM
Using this .js?

your .js (.txt) file is not valid.
if you have an normal .js file, don't write html tags or something else within.
Be sure that nothing else as js in in your file.

like:

//begin your file ---------------

var insdb = true; // these are only examples !

function blabla()
{

}

until end --------------------------


regards

Swon