import javascript like css?


K

Keith Wiley

I am using a basic image swap mouseover javascript for my main menu. The
main menu itself will be visible on all pages on one side of the screen.
If I use frames, then only one file has to describe the menu and
everything is easy. However, I am trying to find a way to avoid using
frames. This would mean that every page has to have the menu on it. I
was hoping to import the javascript from a single file so that any changes
can be implemented in only one place and take effect globally.

Is there any way to do this?

________________________________________________________________________
Keith Wiley (e-mail address removed)
http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
-- Edwin A. Abbott, Flatland
________________________________________________________________________
 
Ad

Advertisements

B

Brett

To import javascript "like css" you can use this:
<SCRIPT type="text/javascript" language="Javascript" SRC="name.js">
</SCRIPT>
just put all your javascript in a file named "name.js"

If your actually trying to have more than just javascript always included
you could use a server side script (like php). Here is an example:

<?php include('myfile.html'); ?>

Then put your menu code in the file named myfile.html
 
A

Adrienne

I am using a basic image swap mouseover javascript for my main menu.
The main menu itself will be visible on all pages on one side of the
screen. If I use frames, then only one file has to describe the menu
and everything is easy. However, I am trying to find a way to avoid
using frames. This would mean that every page has to have the menu on
it. I was hoping to import the javascript from a single file so that
any changes can be implemented in only one place and take effect
globally.

Is there any way to do this?

If you have access to server side script, then you can do a server side
include:
<!--# include file="menu.inc" --> (ASP, SSI)
<?php include("menu.inc"); ?> (PHP)

If you do not have access to server side, then look into a preprocessor.

You really don't want to use javascript include because search engines will
not be able to follow the links, as they do not have javascript enabled.
 
W

Woolly Mittens

Keith Wiley said:
frames. This would mean that every page has to have the menu on it.

Use server-side includes
<!-- #include virtual/includes/myinclude.inc" -->
 
N

Nico Schuyt

Keith said:
I am using a basic image swap mouseover javascript for my main menu.
The main menu itself will be visible on all pages on one side of the
screen. If I use frames, then only one file has to describe the menu
and everything is easy. However, I am trying to find a way to avoid
using frames. This would mean that every page has to have the menu
on it. I was hoping to import the javascript from a single file so
that any changes can be implemented in only one place and take effect
globally.
Is there any way to do this?

Solution was given by Brett already.
One remark: A javascript only menu is worse than using frames (10-15% of the
visitors have javascript disabled)
Nico
 
K

Keith Wiley

Solution was given by Brett already.
One remark: A javascript only menu is worse than using frames (10-15% of the
visitors have javascript disabled)

I don't know what you mean by javascript menu. The only thing I'm using
javascript for is to swap images on mouse over events. The "menu" is just
a set of anchor clickable images.

Thanks.

________________________________________________________________________
Keith Wiley (e-mail address removed)
http://www.unm.edu/~keithw http://www.mp3.com/KeithWiley

"Yet mark his perfect self-contentment, and hence learn his lesson,
that to be self-contented is to be vile and ignorant, and that to
aspire is better than to be blindly and impotently happy."
-- Edwin A. Abbott, Flatland
________________________________________________________________________
 
Ad

Advertisements

D

Derek Clarkson

Hi Keith,
Yes I did it this way:

<div id="menu">
<script type="text/javascript" src="menus.js"></script>
</div>

The only reason I did this was because the dumb ass ISP I am on doesn't
provide any server side scripting facilities on their free web servers. The
problem with doing this is that goodle, yahoo, etc don't scan the resulting
web page, just the raw one. So any links you have are not picked up. The
result for me was that I was not able to get my site to appear in google at
all.

I've now bought site from a commerical hosting site for $50au for 6 months
because they us Linux servers and can provide me with PHP scripting which
lets the server assemble the pages before google gets hold of them. Thus my
site will be correctly indexed by them.

If don't have any server side scripting for assembling your pages, I would
suggest you move to another host. It will make life a lot easier in the
long run.

cio
Derek.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top