Hallo. I want to save a txt file using javascript. I have written some code, but it doesn’t work, I don’t know where is the problem. Please help me.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “
<html xmlns=”
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>
<body>
<script language=”JavaScript” type=”text/javascript” >
function WriteFile()
{
var fh = fopen(“c:
if(fh!=-1) // If the file has been successfully opened
{
var str = “Some text here…”;
fwrite(fh, str); // Write the string to a file
fclose(fh); // Close the file
}
}
</script>
<input name=”button” type=”button” onMouseDown=”WriteFile()” value=”click to save a file” />
</body>
</html>