473,941 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Directory Dialog Box

Is there a way in Javascript to bring up dialog boxes for both opening and
then also saving a file?

Jul 23 '05
12 35603
"rockocubs" <rp*****@nospam .indy.rr.com> writes:

(please remember to include *some* context for your posting)
I dont plan on having the browser open and doing this in an html page, i
guess i was assuming you could run javascript by itself like vbscript


You can. On Windows-boxes, you can use any language supported by the
Windows Scripting Host. E.g., make a file called "test.js" containing:

alert("this works!");

and run it with "wscript test.js".

However, Javascript itself has no method of working with files, or any
other I/O for that matter. All of that is provided by the environment
the script is run in. The environment in browsers is the one assumed
by people in this group unless something else is stated.

If you run your scripts using "wscript", you should consult the
documentation for the Windows Scripting Host to find out what features
are available.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #11
"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:wt******** **@hotpop.com.. .
"rockocubs" <rp*****@nospam .indy.rr.com> writes:

(please remember to include *some* context for your posting)
I dont plan on having the browser open and doing this in an html
page, i
guess i was assuming you could run javascript by itself like vbscript
You can. On Windows-boxes, you can use any language supported by the
Windows Scripting Host. E.g., make a file called "test.js" containing:

alert("this works!");

and run it with "wscript test.js".


And get the error:
Script: \path\test.js
Line: 1
Char: 1
Error: Object expected
Code: 800A138F
Source: Microsoft JScript runtime error
However, Javascript itself has no method of working with files, or any
other I/O for that matter. All of that is provided by the environment
the script is run in. The environment in browsers is the one assumed
by people in this group unless something else is stated.
The error encountered above is precisely because of this fact. alert()
is a method provided by the default global object to scripts executing
in Internet Explorer. alert() is not a method available to scripts
running in wscript/cscript because the host does not expose/provide such
a method.

To popup a dialog in wscript, you'd use:

WScript.Echo("t his works!");

(note this echos to the console when the script is executed with cscript
test.js).

To have a version that does the equivlent of alert() for both wscript
and cscript, you'd use:

var wshShell = new ActiveXObject(' WScript.Shell') ;
wshShell.Popup( "this works!");
If you run your scripts using "wscript", you should consult the
documentation for the Windows Scripting Host to find out what features
are available.


Indeed.

For relatively clean list of available WSH objects, properties and
methods, I prefer <url:
http://www.devguru.com/Technologies/...h_objects.html />

All the objects available there are instatiated (with the exception of
TextStream, which is returned by the StdErr, StdIn and StdOut properties
of the WScript object) in JScript using:

var wshWhatever = new ActiveXObject(' WScript.Whateve r');

There are also all sorts of other ActiveXObjects which are available
from WSH, such as the FileSystemObjec t <url:
http://msdn.microsoft.com/library/en...FileSystem.asp
/>

Note that these references are in no way intended to be a complete list
of references, only a sample of the types of references available on the
Web. Other references can be obtained by using Google to search for
something like:

"<object you are interested in> activexobject site:microsoft. com"

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #12


*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #13

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

Similar topics

7
16231
by: Martin | last post by:
Again drawing on the groups experience:- 1. For general file opening and file saving, using VB6, are there any issues with using the FileOpen and FileSave Common Dialog Boxes? 2. Is using the FileOpen and FileSave Common Dialog Boxes the best way to go in general? 3. For Most of my projects I will be using the same types of data input form and report output form, as discussed here recently. Also, the files that are
3
10809
by: bbxrider | last post by:
running win2k adv server/ iis5.0 trying to setup on my web page where browsers can download a file, an .xls so been trying to figure out with a download 'link' what invokes the standard ms file save dialog, hopefully without using vbscript other web pages i have seen have a simple link such as : <a href="someDir/someFile.xls">Download</a> when i used that, it just opens the spreadsheet and actually allows me to use the spreadsheet...
5
11071
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been created in the wrong folder on the hard drive. Before I discovered these files, .NET kept trying to create a new project with _1 following the project name. Deleting those files corrected that problem. I deleted the Virtual Directory, rebooted, and...
2
2402
by: yanivoliver | last post by:
Hey, I'm currently trying to find a way to open a dialog box that will allow me to select more than one file at a time, so if I want to upload select all the files in a directory, I won't have to have the number of dialog boxes as files in the directory. I was thinking of using a ActiveX control, but I don't want to make the sure download additional components to be able to do this, so is there maybe some sort of Windows ActiveX control...
0
1375
by: thomasp | last post by:
Wrong title should be File Save Dialog. I have a VB2005 program that has to import data from a 3.5 floppy drive and USB drives. I use a file open dialog to choose the file, works great. The problem occurs the next time I wish to open a file. If the last import was done from a floppy drive the program looks for a floppy drive first and if it has been removed I get an error. While I could just catch the error, I would rather know how...
5
12333
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. On Beta1, I am able to execute a particular page with no problem, that page opens up in the comes up just fine. On Win2kdev1, when I go to execute the same page, it opens a file download dialog and asks me whether I want to open or save the...
3
11084
by: Highlander | last post by:
Hello all. Consider the following HTA: <HTML> <HEAD> <TITLE></TITLE></HEAD> <BODY> <SCRIPT LANGUAGE="VBScript"> Sub ButBrowse_onclick() '-- show browse window and Get file path:
11
2218
by: GaryDean | last post by:
We created a "File" website on XP and transferred it over to server2003. Now we want to change it to an HTTP site. Without creating a new project and importing everthing, it there a way to convert it? the properties show file:///C:/Inetpub/wwwroot /etc. but it can't be changed to HTTP. It's got to be somewhere in some configuration file. -- Regards, Gary Blakely
3
5880
by: ArmageddonAsh | last post by:
I'm trying to make an application that will allow the user to enter data into a flexgrid (that's done) and then save the data from that flexgrid into a CSV file but even though the file is made none of the data from the flexgrid goes into the CSV file and so I have a couple of questions. 1, How do I make the application load the data from a specific CSV file? 2, How do I make it so that the user is able to add information to the data and...
1
47535
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
10135
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9968
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11531
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11119
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11297
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10660
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8219
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4909
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
3
3509
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.