Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Best way to write a text file on local machine w/Firefox ?

Posted on 2008-06-12
10
Medium Priority
?
274 Views
Last Modified: 2013-12-07
I was trying to do it through javascript (which works on IE7, but only with a yes/no security box), below is the code.  This gives an error in firefox error console: "ActiveXObject is not defined".

OK... so is there a way to get javascript to do it?  Or is there another way to get firefox to write a file on the local machine or even better, a machine on the local network?  It doesn't have to be javascript, it can even be a 3rd party plugin or something.  There is no real server, just a bunch of workstations on a local network.

This is going to be running only my website and will not be connected to the internet, so I have no problems totally opening up the security options.


function WriteToFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var FileObject = fso.OpenTextFile("C:\\_PhotosViewing\\order.txt", 2, true,0);
strOutput="blah blah"
FileObject.write(strOutput)
FileObject.close()
}

Open in new window

0
Comment
Question by:BossTurbo
  • 7
  • 3
10 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 21775521
BossTurbo,

You can try installing the IETab addon (http://addons.mozilla.org/firefox/addon/1419) to your Firefox.  That could be a way to get your code to work, as long as Firefox security doesn't stop it.

Firefox doesn't support ActiveX objects natively.  They are an MS technology.  The addon is a way around this.

The other limitation, which the addon won't affect, is FIrefox's security.  If the page is a local page then this may work.  If it is an Internet page then the browser will not allow the page to mess with local files.  In Firefox you won't even get the security box.

Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 21775528
BossTurbo,

If you the security won't allow it then you will need to make an applet (i.e. Java applet) to do this.  The applet should be signed to for best results.  This probably isn't something you can download though, too specific, so you will have to develop it or have someone do it.  Applets can be allowed to do things like this, even in Firefox.

Let me know if you have a question.

b0lsc0tt
0
 

Author Comment

by:BossTurbo
ID: 21776105
Hmm, I tried the IE tab and it does work kind of, it pops up an error dialog box when executing the ActiveX code, which is one of the reasons I'm avoiding the IE route in the first place.  I don't think the java applet will work since I have to pass variables from a javascript file that is in use on the page to the text file... the contents of a shopping cart.  I'm wondering if I can just pull the cart contents from a cookie file from a local system run vbscript and do the file management that way... a total hack, but if it works...  Thoughts?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 21780413
>> I'm wondering if I can just pull the cart contents from a cookie file from a local system run vbscript and do the file management that way... a total hack, but if it works...  Thoughts? <<

Would this be with script in the browser or just vbscript in something like a vbs file run locally?  If in a browser then it won't work.  Browsers are serious about security, especially protecting local files.  If the security alert in IE is too much for you then you are out of luck doing this in a browser.

Will the protocol in the URL of this be http:, file:, http://localhost, or something else?  It won't change what I just said but may affect options if you try to pursue an applet/object for the browser.

If you just mean a local vbs file then that will work.  Not my expertise but since it runs locally it will have the normal permissions to do things that the user has.  Reading a cookie's contents is not easy and that folder is a little protected by Windows but a vbs file can create and write a local text file.

bol
0
 

Author Comment

by:BossTurbo
ID: 21828325
OK, I've just decided to use IE anyway, so far the only issue is the security error box when the activex object runs.  Any ideas around this?  I've read try using .hta file?  Or registering the script as a safe script??  Any ideas?  I'll give you points b0lsc0tt either way since you've helped.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 21828830
Not with an hta or safe script setting.  What you mentioned above helped us rule them out earlier.  I haven't actually developed a toolbar so I don't know if there is something unique about them.  That may provide a way but the trouble would still be with the page.  The browser is going to still protect the page and content.

If an install is OK to provide this then you might look at a Browser Helper Object (BHO).  You can start by looking at http://msdn.microsoft.com/en-us/library/Bb250436.aspx .  From what I have read about them they may allow the type of control and access you want and need.

Other common IE development "tools" are listed at http://msdn.microsoft.com/en-us/library/aa753587.aspx .  I don't think any of those will be more useful but thought you might like the info and list.

Let me know if you have a question.  I am glad I have been able to help and hope this will be especially helpful.

bol
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 21828896
Please disregard my comment above.  It is getting late and I mixed up questions.  I have to reread this and I will post a response (that actually makes sense). :)

bol
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 2000 total points
ID: 21828939
Here is my real response. :)

Since this isn't on a web server or an Internet page an HTA file may help.  IE may still bring up a security message but security is looser for an HTA.  They can only be run locally so it is expected that you are OK with what it does.  I do believe I have still seen some warnings though so it may not be much better.  I don't use them often enough to remember the differences.

To make the file you should be able to just rename the file.  Let it end with .hta instead of .htm or .html.  Then click on it with the mouse or run it to have the browser open the file.  These files will only work in IE.

Let me know how this helps.  Sorry about my previous post.  I will actually delete it later so the question is cleaner.

bol
0
 

Author Closing Comment

by:BossTurbo
ID: 31466799
Hi b0lsc0tt,  Thanks for the time spent on the question, definetely helps alot even there is no clear solution.  There just is no way around IE's security box and firefox wont run activeX unfortunately.  The .hta file worked with no warning box, but has other issues.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 21858583
Your welcome!  I'm glad I could help.

I have posted your grading comments below.  The info in them is helpful and at this time EE only shows them to the Asker and Experts with accepted/assisted comments.

Thanks for the grade, the points and the fun question.

bol

Grading Comments:
Hi b0lsc0tt, Thanks for the time spent on the question, definetely helps alot even there is no clear solution. There just is no way around IE's security box and firefox wont run activeX unfortunately. The .hta file worked with no warning box, but has other issues.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question