Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > import javascript like css?

Reply
Thread Tools

import javascript like css?

 
 
Keith Wiley
Guest
Posts: n/a
 
      11-03-2003
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
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
__________________________________________________ ______________________
 
Reply With Quote
 
 
 
 
Brett
Guest
Posts: n/a
 
      11-04-2003
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

--
Brett
Provision Tech
http://www.provisiontech.net

"Keith Wiley" <> wrote in message
news .edu...
> 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
> 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
> __________________________________________________ ______________________



 
Reply With Quote
 
Adrienne
Guest
Posts: n/a
 
      11-04-2003
Gazing into my crystal ball I observed Keith Wiley <>
writing in news .edu:

> 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.

--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com
 
Reply With Quote
 
Woolly Mittens
Guest
Posts: n/a
 
      11-04-2003
"Keith Wiley" <> wrote in message
news .edu...
> frames. This would mean that every page has to have the menu on it.


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


 
Reply With Quote
 
Nico Schuyt
Guest
Posts: n/a
 
      11-04-2003
Keith Wiley wrote:
> 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


 
Reply With Quote
 
Keith Wiley
Guest
Posts: n/a
 
      11-04-2003
On Tue, 4 Nov 2003, Nico Schuyt wrote:

> 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
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
__________________________________________________ ______________________
 
Reply With Quote
 
Derek Clarkson
Guest
Posts: n/a
 
      11-06-2003
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.

Keith Wiley wrote:

> 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
> 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
> __________________________________________________ ______________________


--
cio
Derek
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Aliasing "namespaces" in JavaScript--why do we need to import symbols into a new namespace? Ray Javascript 1 01-27-2007 11:42 PM
Import Javascript effect into html body Viabug123 HTML 1 04-21-2006 06:50 AM
JavaScript Import file problem Joseph Scoccimaro Javascript 1 11-21-2005 04:37 PM
Import Semantics, or 'What's the scope of an import?', and classattribute instantiation Andrew James Python 1 12-04-2004 02:28 PM
Javascript equivalent of #include or @import? Weston C Javascript 16 01-25-2004 09:43 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57