By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,695 Members | 1,651 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,695 IT Pros & Developers. It's quick & easy.

javascript file (.js) on hard disk

P: n/a
Hello everyone,

What is the correct way to incorporate a .js file into an HTML file
*IF* the .js file on a hard disk?

What I have tried is listed below but it does not work... When trying
to access a function module in one of the .js files, I get an error
that the function module is not defined (which would lead me to believe
that it is not being imported with the .js "src" instruction.

Does anyone know how to get around this?

TIA.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
</HEAD>
<SCRIPT language="javascript1.2"
src="file:///C:\row_functions.js" >
</script>
<SCRIPT language="javascript1.2"
src="file:///C:\data_check_functions.js" >
</script>
<SCRIPT language="javascript1.2" ><!--

---- CUT out some executed functions -----
--></SCRIPT>
<BODY>

----- CUT out the rest

Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
milkyway wrote:
Hello everyone,

What is the correct way to incorporate a .js file into an HTML file
*IF* the .js file on a hard disk? [snip]

<SCRIPT language="javascript1.2"
src="file:///C:\row_functions.js" >
</script>
<SCRIPT language="javascript1.2"
src="file:///C:\data_check_functions.js" >
</script>


Those back slashes ("\") don't look correct to me, but I develop on Mac.
Why not place the external files in the same directory as the ppage?
I assume you are previewing locally.
Mick
Jul 23 '05 #2

P: n/a
On 16 Jan 2005 08:53:48 -0800 milkyway wrote:
Hello everyone, What is the correct way to incorporate a .js file into an HTML file
*IF* the .js file on a hard disk?

Same as you would for on a website.

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

list the "src" first.
Your src file should be in the same directory as the calling file.
if not, then use src="path/filename.js".
BTW, DO NOT use the C:\ root directory for anything but the OS files.
Always put your personal files into folders.
Jul 23 '05 #3

P: n/a
In article <11**********************@c13g2000cwb.googlegroups .com>,
"milkyway" <d0******@hotmail.com> wrote:
Hello everyone,

What is the correct way to incorporate a .js file into an HTML file
*IF* the .js file on a hard disk?

What I have tried is listed below but it does not work... When trying
to access a function module in one of the .js files, I get an error
that the function module is not defined (which would lead me to believe
that it is not being imported with the .js "src" instruction.

Does anyone know how to get around this?

TIA.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252">
</HEAD>
<SCRIPT language="javascript1.2"
src="file:///C:\row_functions.js" >
</script>
Here is an example if both files are in the same folder.

<script type="text/javascript"
src="domwalker.js"></script>
The backslash only works in IE. Use the forward slash instead. Also,
the \ is a javascript escape character. You might try //.
<SCRIPT language="javascript1.2"


Do you know that javascript1.2 uses a different definition of equal (=)
inside an if statement? If do not know the difference you want to use
this line:
<script type="text/javascript">
Jul 23 '05 #4

P: n/a
In article <ba*********************@twister.nyroc.rr.com>,
Mick White <mw***********@rochester.rr.com> wrote:

Why not place the external files in the same directory as the ppage?

An advantage of this is that you will not have to change your code when
you move it to the server.

Robert
Jul 23 '05 #5

P: n/a
Hello again everyone,

Thank you so much for your responses and advice :-)))

I found out what the problem was. In the immortal words of Charlie
Brown: AUUUGGGGGH!!!!!

Basically, I created the files using the Windows interface. I saved
them with the name of check_functions.js - well, it so happens that
this *#$#%%@ thing saved it as check_functions.js.txt!!!

When I went to the OS level and changed it to check_functions.js, all
worked OK!!!

Kindest Regards.
Robert wrote:
In article <ba*********************@twister.nyroc.rr.com>,
Mick White <mw***********@rochester.rr.com> wrote:

Why not place the external files in the same directory as the
ppage?

An advantage of this is that you will not have to change your code when you move it to the server.

Robert


Jul 23 '05 #6

P: n/a
Robert wrote:
In article <11**********************@c13g2000cwb.googlegroups .com>,
"milkyway" <d0******@hotmail.com> wrote:

<--snip-->
<SCRIPT language="javascript1.2"

Do you know that javascript1.2 uses a different definition of equal (=)
inside an if statement?


Only in certain browsers.
If do not know the difference you want to use this line:
<script type="text/javascript">


You should use the type attribute even if you *do* know the difference.
Unless you are after one of the quirks that 1.2 invokes in Netscape 4

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.