471,582 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

javascript file (.js) on hard disk

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

Similar topics

8 posts views Thread by Lu | last post: by
6 posts views Thread by milkyway | last post: by
4 posts views Thread by Carlitos | last post: by
6 posts views Thread by Alan Wang | last post: by
3 posts views Thread by noridotjabi | last post: by
1 post views Thread by tsxn26 | last post: by
12 posts views Thread by glennanthonyb | last post: by
reply views Thread by XIAOLAOHU | last post: by
1 post views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.