473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 1518
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Lu | last post by:
Hi there, I got a program to write data to a randomly accessed file (the program moves file pointer to a certain position of the file according the current "keyword" and then writes data). It...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
1
by: Tim | last post by:
Hi, We are downloading a few thousand rows of data for users to choose from and need to speed up the operation. The data is related in four levels. The current design allows the user to select...
6
by: milkyway | last post by:
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...
4
by: Carlitos | last post by:
I have researched a lot trying to get this. So as a last resource I will have to ask here. What would be the equivalent to the following javascript excerpt: TheDataManager MyDMgr = new...
6
by: Alan Wang | last post by:
Hi All, My application puts standard output from command line(using process.start()) into a file on the hard disk then reads the info from that file after command has finished. The problem is...
3
by: noridotjabi | last post by:
Say I'm writting a program. In this program for some reason I need to store data somewere were I will be able to access it again. I don't want to store it in a file because then it could be...
1
by: tsxn26 | last post by:
Does anyone know of a javascript that will popup a dialog box similiar to the "Save to" & "File upload" boxes but insteads let's you choose a path and will return the path to a text box? What I...
12
by: glennanthonyb | last post by:
Hi The company I work for has finally woken up to data security on our field laptops. I'm writing something in C# that will allow remote deletion of sensitive data and I don't believe...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.