Hey all,
I am having problems creating/using a .js file.
At first, I wanted to overwrite a previous javascript used in the page that's running, but it kept creating the .js on my desktop or getting lost completely... if not erroring. So I decided to put the .js on the root directory itself, without any luck at all. When I run the .htm, it acts as though the file is there, but blank -- not erroring. The file is there and not blank, I added it myself!
The .js is a data file and the .htm is supposed to update it with a form created with a preloaded javascript.
I'm a bit of a newbe and tend to learn best by example, so examples would help greatly and are vary appreciated. :)
Here is what I have:
On the .htm... - <script src="\\examplefilename.js"></script>
-
<script src="\\preloadfile.js"></script>
-
On preloading .js file that makes the form, .js and controls the .htm content... - ...
-
for (i=0;i<21;i++) {
-
if (ln[i][0]!="blank") {pine[i]="...data...";}
-
else
-
{pine[i]="blank";};
-
};
-
-
var filename="\\examplefilename.js";
-
var fso = new ActiveXObject("Scripting.FileSystemObject");
-
var FileObject = fso.OpenTextFile(filename,2, true, 0);
-
for (i=0;i<21;i++) {if (pine[i]!="blank") {
-
FileObject.writeline(pine[i]);};
-
}
-
FileObject.close();
-
}
-
...
Thanks in advance for your help!
4 4685
Hey all,
I am having problems creating/using a .js file.
At first, I wanted to overwrite a previous javascript used in the page that's running, but it kept creating the .js on my desktop or getting lost completely... if not erroring. So I decided to put the .js on the root directory itself, without any luck at all. When I run the .htm, it acts as though the file is there, but blank -- not erroring. The file is there and not blank, I added it myself!
The .js is a data file and the .htm is supposed to update it with a form created with a preloaded javascript.
I'm a bit of a newbe and tend to learn best by example, so examples would help greatly and are vary appreciated. :)
Here is what I have:
On the .htm... - <script src="\\examplefilename.js"></script>
-
<script src="\\preloadfile.js"></script>
-
On preloading .js file that makes the form, .js and controls the .htm content... - ...
-
for (i=0;i<21;i++) {
-
if (ln[i][0]!="blank") {pine[i]="...data...";}
-
else
-
{pine[i]="blank";};
-
};
-
-
var filename="\\examplefilename.js";
-
var fso = new ActiveXObject("Scripting.FileSystemObject");
-
var FileObject = fso.OpenTextFile(filename,2, true, 0);
-
for (i=0;i<21;i++) {if (pine[i]!="blank") {
-
FileObject.writeline(pine[i]);};
-
}
-
FileObject.close();
-
}
-
...
Thanks in advance for your help!
Java != Javascript
Moved to Javascript forum
Welcome to TSDN!
Use forward slashes instead of backward slashes.
Why are you using ActiveX to read a Javascript file? If you include the Javascript file, the data should be available as long as it's been entered and is accessed correctly. What are the contents of examplefilename.js?
Welcome to TSDN!
Use forward slashes instead of backward slashes.
Why are you using ActiveX to read a Javascript file? If you include the Javascript file, the data should be available as long as it's been entered and is accessed correctly. What are the contents of examplefilename.js?
I'm only using ActiveX to write to the file. I tried using the forward slashes but it still ignores the files existence without error. These arrays hold preset page color codes and I'm trying to make them changeable so that the end user can change them once they have downloaded the self-extracting "mini-site".
OK, now I feel like a total fool. I was monkeying around with it and stumbled onto the solution, kinda. I'm still not vary clear as to how the path got messed up, but I think it had something to do with the fact that the preload.js was calling itself upon loading a .html that was created entirely by the preload.js.
Anywho, all I really needed to do was to rename the filename variable (examplefilename.js) to the literal address on the computer (something like 'c:/foldername/foldername/examplefilename.js') instead of trying to back-track with '//examplefilename.js' or '../../folder/examplefilename.js'.
This doesn't really work to keep it useable if the mini-site is put other folders. However, since it's a self-extracting archive that will automatically place the mini-site where it needs to be, that's ok, I guess.
I thank you for your assistance and appologize for any inconvenience this has caused. If you would like to explain to me how this path got messed up I'd love to know the answer so I can use the correct 'auto-addressing' to avoid problems if the mini-site is moved and so I can just archive the mini-site as a .zip. :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason Heyes |
last post by:
Does this function need to call eof after the while-loop to be correct?
bool read_file(std::string name, std::string &s)
{
std::ifstream in(name.c_str());
if (!in.is_open())
return false;
...
|
by: ben beroukhim |
last post by:
I have huge number of legacy code which use standard files functions.
I would like to pass a memory pointer rather than a FILE pointer.
I am trying to use FILEs in the code to refer to memory...
|
by: DazedAndConfused |
last post by:
Can you encrpt a serialized object?
Or am I trying to do something that just doesn't work that way?
I am trying to encrypt a serialized object. I can read and write the object
to a file...
|
by: a |
last post by:
I have a struct to write to a file
struct _structA{
long x;
int y;
float z;
}
struct _structA A;
//file open
write(fd,A,sizeof(_structA));
//file close
|
by: dasilva109 |
last post by:
Hi guys
I am new to C++ and need urgent help with this part of my code for a
uni coursework I have to submit by Thursday
//ClientData.h
#ifndef CLIENTDATA_H
#define CLIENTDATA_H
#include...
|
by: agphoto |
last post by:
There is big or problem in open file in read and write mode..
$file = "data.txt";
$fp = fopen($file,"w+");
$line = fgets($fp,"120"); // i need only 1st line to read and upto 120 bytes
echo...
|
by: Frederic Rentsch |
last post by:
Hi all,
Working with read and write operations on a file I stumbled on a
complication when writes fail following a read to the end.
30L
'abcdefg'
Traceback (most recent call last):
File...
|
by: thiago777 |
last post by:
I have only 1GB of RAM so I cannot work with files too big with the ReadtoEnd method.
Here is the code Im trying so that the file would split in pieces of 256MB:
Try
Dim BInput...
|
by: vineeth |
last post by:
Hello all,
I have come across a weird problem, I need to determine the amount
of bytes read from a file, but couldn't figure it out ,
My program does this :
__
file = open("somefile")
data =...
|
by: Sachin Garg |
last post by:
I have a program which opens a fstream in binary input+output mode, creating
the file if it doesn't exists. But writing doesn't works after reading, it
must be something obvious that I am not aware...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
| |