• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

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

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
BossTurbo
Asked:
BossTurbo
  • 7
  • 3
1 Solution
 
b0lsc0ttIT ManagerCommented:
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
 
b0lsc0ttIT ManagerCommented:
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
 
BossTurboAuthor Commented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
b0lsc0ttIT ManagerCommented:
>> 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
 
BossTurboAuthor Commented:
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
 
b0lsc0ttIT ManagerCommented:
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
 
b0lsc0ttIT ManagerCommented:
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
 
b0lsc0ttIT ManagerCommented:
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
 
BossTurboAuthor Commented:
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
 
b0lsc0ttIT ManagerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now