473,586 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing a variable in another file & file ops.

Hello,

Two newbie questions:

1) I have a javascript file with a function in it. From this function
I want to access a variable in another javascript file -which is not
inside a function. I have tried many combinations to do this, but has
yet to try the right one. How is it done?

2) What kinds of file operations can be done in Javascript (save,
read, write)? As far as I know all file operations are possible using
Java within your Javascript. But can't it be done using Javascript
only? (I'm talking file operations on my own files on my ISP's
server).

Thanks
/Peter
Jul 20 '05 #1
3 12384

"Peter" <pt****@hotmail .com> wrote in message
news:5e******** *************** ***@posting.goo gle.com...
Hello,

Two newbie questions:

1) I have a javascript file with a function in it. From this function
I want to access a variable in another javascript file -which is not
inside a function. I have tried many combinations to do this, but has
yet to try the right one. How is it done?

2) What kinds of file operations can be done in Javascript (save,
read, write)? As far as I know all file operations are possible using
Java within your Javascript. But can't it be done using Javascript
only? (I'm talking file operations on my own files on my ISP's
server).

Thanks
/Peter


I can't answer your first question (though I suggest either making the code
available via a hyperlink or if its not too huge, including it with your
post in summary form and I'm sure someone would more quickly answer your
question).

With regards to question 2 - Javascript does not permit, nor does it contain
any functionality for disk access of any sort (ie you cannot
read/write/copy/move/whatever a file). This also means that you cannot even
perform anything so simple as a 'dir' or 'ls -l' or whatever command to list
files in a directory...
Jul 20 '05 #2
Hi,

Peter wrote:
Hello,

Two newbie questions:

1) I have a javascript file with a function in it. From this function
I want to access a variable in another javascript file -which is not
inside a function. I have tried many combinations to do this, but has
yet to try the right one. How is it done?
You must include your other JS file with

<SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript"
SRC="yourOtherF ile.js"></SCRIPT>

After that, all the variables defined in the other file are available to
the script. All files and partial scripts are loaded in the page, so
that it becomes, in the end, one whole. This can cause problems,
however, especially if 2 global variables have the same name.

2) What kinds of file operations can be done in Javascript (save,
read, write)? As far as I know all file operations are possible using
Java within your Javascript. But can't it be done using Javascript
only? (I'm talking file operations on my own files on my ISP's
server).
I accept that you're speaking about client-side JavaScript. There are so
many possible configurations that it's impossible to detail all of them.
If you're talking about client-side operations on server-side files,
your possibilities are almost zero. All files operations should be
realized on the server, where you can very well use server-side
JavaScript (for example on ASP). A client-side Java applet can list
files in a directory on the server it originates from (if the server
allows directory browsing) and also read a file (text or binary).
Examples at
http://www.galasoft-LB.ch/myjava/Web...Demo/Demo.html

With the correct permissions set, client-side JavaScript can also use
ActiveX (on IE only) to perform local file operations (list, write,
read...). In Netscape, local file operations can be performed using Java
File objects, once again in a relaxed security environment. But it's not
what you need and I mention it only for memory.

Thanks
/Peter


Detail exactly what you're trying to do, and I'll tell you if it's possible.

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #3
Well, I have a .js file with a function in it which can build a html
page. Something like this:

function buildPage(showC ontent) { // see below for info on
*showContent*
var header = "<html><head><t itle>SomeTitle</title></head><body>";

var footer = "</body></html>";

var page = header + content + footer; // see below for info on
*content*

document.write( page);
}

The argument *showContent* contains the .js file to access. This .js
file contains a variable called *content* which could look something
like this:

var content = "<p>This is the content</p>";

How do I access this variable? It needs to be in another file as I
have multiple files with the variable *content* containing different
information.

Thanks in advance for any help.

/Peter
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
2896
by: Lamberti Fabrizio | last post by:
Hi all, I've to access to a network file from an asp pages. I've red a lot of things on old posts and on Microsoft article but I can't still solve my problem. I've got two server inside the same NT domain, each one has its own web server. The web server is always IIS 5.0.
6
2734
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is called "form1", and I have selects called "PORTA", "PORTB" ... etc...
4
3757
by: Khalique | last post by:
I have built a web service whose purpose is to copy files from a secure place to client machine and vice versa. The problem I am having is perhaps related to permissions and access rights. For testing purposes, the secure place is setup on the client machine. The client (window app) calls the web service (on a different machine) and connects...
89
6003
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be used." Could anybody tell me why gets() function is dangerous?? Thank you very much. Cuthbert
2
2343
by: Jurek Dabrowski | last post by:
hi all, I have a question in reference to accessing variables in another class maybe someone has dealt with before. I have some public variables declared in my main plug-in class CCommandMeshToSrf, eg: BOOL m_bHaveAnswer; I want to set this variable from within a dialog class which is defined in separate .h and .cpp files of course. How...
4
9049
by: John Kotuby | last post by:
Hi all, I am using a Repeater in conjunction with a SQLDatasource and SQL Server. One of the controls in the repeater is a HyperlLink as follows: <asp:HyperLink NavigateUrl='Search.aspx?page=base&amp;searchid=<% Eval("sequence")%>' ..... As you can see I am trying to pass a QueryString evaluated at runtime. All the other Evals of DataFields...
12
3102
by: titan nyquist | last post by:
I have a class with data and methods that use it. Everything is contained perfectly THE PROBLEM: A separate thread has to call a method in the current instantiation of this class. There is only ever ONE instantiation of this class, and this outside method in a separate thread has to access it. How do i do this?
3
3074
by: djsuson | last post by:
I'm trying to set up an inheritance tree that also uses templates. This is an attempt to simplify some previous code that was filled with redundancies. I'm working with g++ 3.4.6. The code is split over four files: two headers and two implamentation files, but uses the include trick mentioned on another thread to connect the header and...
2
1573
by: Newbie | last post by:
Hi, I have a situation where my application is trying to access a file, that another application may have temporalily open. The error I get is The process cannot access the file 'C:\picks\test50k.gp1' because it is being used by another process.
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7954
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.