Solved

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

Posted on 2008-06-12
10
263 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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 500 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WebSite Direction 1 40
Delay Form Submission without touching existing code? 5 22
Can not open the Access Help ? 3 53
HTML5 frame 5 25
Internet is a big network which is formed by connecting multiple small networks.It is a platform for all the users which are connected to it.Internet act as platform in different fields. Such as: Internet  as a collaboration platform. Internet  as…
This article discusses how to create an extensible mechanism for linked drop downs.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

776 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