【问题标题】:How to save a textarea as a text file如何将文本区域保存为文本文件
【发布时间】:2015-06-13 16:29:29
【问题描述】:

我试图用 html 制作我自己的类似于 microsoft word 的软件。基本上我有一个文本区域,他们输入文本并保存。问题是,当我将它保存到我的计算机以在每次重置 textarea 时对其进行测试时。我有一个按钮,它执行一个 javascript 警报框,告诉按“CTRL+S”来保存文件,但正如我所说,我重置了 textarea。除了 textarea 标签之外,是否还有其他标签,或者我只需要一种不同的方法来保存文件。如果您有任何代码建议,请与我分享,谢谢! 这是我的代码:

 textarea {
    background-color: #E6E6E6;
    }
     </style>
</head>
<body>
    <div class="container">
        <div class="jumbotron">

            </h1>
            </div>
        </div>
        </div>


        <button onclick="myFunction()">
              <noscript>
                <b> Press CTRL+S And Name It Something (---------).html </b>
            </noscript>Save
        </button>



        <script>
      function myFunction() {
      alert("To Save Press CTRL+S And Name It Something (---------).html ");
      }
        </script>

【问题讨论】:

标签: javascript html file save textarea


【解决方案1】:

如果您在浏览器窗口中按 CTRL+S,浏览器将保存来自服务器(这里是您的本地计算机)的原始 html。在这种情况下,html 本身不包含文本,因此不会保存。

如果您想保存输入的文本,您必须创建一个单独的函数来将 textarea 内容包含在 html 中。

【讨论】:

    猜你喜欢
    • 2012-12-31
    • 2012-04-11
    • 2018-07-13
    • 1970-01-01
    • 2014-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-29
    相关资源
    最近更新 更多