以下のようなサーバーの応答があり、javascript を使用して html ファイルを作成し、ローカル マシンに保存したいと考えています。
HTMLファイル
<!DOCTYPE html>
<html>
<head>
<script>
function copyText()
{
}
</script>
</head>
<body>
Field1: <input type="text" id="field1" value="Hey There"><br>
Field2: <input type="text" id="field2">
<br><br>
<button onclick="copyText()">Copy Text</button>
<p>A function is triggered when the button is clicked. The function copies the text from Field1 into Field2.</p>
</body>
</html>
javascriptを使ってファイルを作成することはできますか?
使ってみた
fso = new ActiveXObject("Scripting.FileSystemObject");
thefile=fso.CreateTextFile("C:\\tmp\\MyFile.txt",true);
write(responseHtmlStr)
クロムでは、「Uncaught ReferenceError: ActiveXObject is not defined」というエラーが表示されました
セキュリティ上の脅威により不可能であるとどこかで読みました。いくつかの指針を教えてください。とても役に立ちます。
ありがとうゲンダフル