Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  80] [ 1]  / answers: 1 / hits: 17443  / 14 Years ago, fri, november 26, 2010, 12:00:00

Situation:-
I have created a installation setup(local) that returns a URL eg:- ved.test.com which is mapped to an IP 11.22.33.44.
Thus to make the web application accessible after installation, user has to make an entry in the hosts file under C:WINNTsystem32driversetc directory explicitly.



Approach:-
After the installation application gets completed, application writes the file using Javascript.



Problem:-
Writing a File using Javascript is supported in IE. I need a Solution for Firefox.
Code used:-



<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content=text/html; charset=utf-8 />
<title>Write To A File</title>
<script language=javascript>
function WriteToFile()
{
/* The below statement is supported in IE only */
var fso = new ActiveXObject(Scripting.FileSystemObject);
var s = fso.CreateTextFile(C:\Test.txt, true);
s.WriteLine('IE Supports Me!');
s.Close();
}
</script>
</head>
<body onLoad=WriteToFile()>
</body>
</html>


Have also refered the link in SO:-
How to read and write into file using JavaScript



Kindly provide a solution that supports writing a file using Javascript that runs in Firefox browser.



Thanks in Advance.


More From » firefox

 Answers
27

You can't do this, for hopefully obvious security reasons. JavaScript has no access to the file system...in IE it's not JavaScript, but ActiveX doing this...it just has a JavaScript API exposed.



The problem isn't that Firefox doesn't do this...it's that IE ever allowed it :)


[#94838] Tuesday, November 23, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
virginia

Total Points: 632
Total Questions: 95
Total Answers: 95

Location: China
Member since Mon, Aug 22, 2022
2 Years ago
;