External file forJavaScript

F

Fred

Can anyone please tell me how I can create an external file for JavaScript.
According to IBM, I need to use an external file for my JavaScript and
Stylesheet code. Any help for a novice would be much appreciated. If you
need to take a look at one of my pages (produced in FP 2002) please visit
http://www.book-holidays-direct.com/Jamaica.htm
 
F

Fred

Thanks for the quick reply. Could you please tell me how I go about creating
the external file. Do I use and text editor or what? Can this be done using
FrontPage, i.e. produce a page without the top & bottom boarders or what.
Sorry to be so ill informed.
 
S

Steve Easton

Using notepad and saving the file with the .js or .css extension.
Note that an external script file contains the actual script, but it does *not* contain the opening
and closing script tags.

Then place the following between the head tags of the page:
<script type="text/javascript" src="filename.js"></script> for a javascript
and
<link rel="stylesheet" type="text/css" href="filename.css"> for a style sheet
--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
M

Murray

Actually, correct syntax would be -

<script type="text/JavaScript" src="yourpage.js"></script>

To create an external file for either javascript or CSS, you would just use
Notepad, or TextEdit, and copy all of the javascript or CSS from your page,
and paste it into a new document in said editors. Then go through what you
pasted and make sure it contains NO HTML tags, e.g.,

<!--

or

<style....

or

<script...

In other words, the external javascript file should contain *only*
javascript, and the external CSS file should contain *only* CSS.

Save the properly formatted and edited files, and link to them as already
shown. That's all there is....
 
F

Fred

Can you please tell me what command I place in the body of the page where I
want the script to appear.
 
S

Steve Easton

That depends on what you're trying to do with your script, what the script is supposed to do!!

Is it an automatic thing or is it dependent upon user input with a mouse??

What is it's purpose??

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
M

Murray

It would depend on what the script was doing, and what the name of the
function that you need to call is.
 
F

Fred

Hi Murray and Steve,

It's an hotel search box which obviously has a lot of JavaScript in it and I
need it to load half way down the page. Would I be right in guessing that I
insert <SCRIPT SRC="thescript.js">
</SCRIPT> where I want it to appear.
 
S

Steve Easton

Yes

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
S

Steve Easton

Place it in a table or cell

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
M

Murray

Not necessarily. It would depend on what the contents of thescript.js
is/are. If it contains only function definitions, then you might need to do
something like this -

<script type="text/javascript">calltheFunction()</script>

Did you get any instructions with the script?
 

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