如何使用Javascript变量保存为客户端PC上的文件 [英] How to save Javascript variable as file on the client PC

查看:156
本文介绍了如何使用Javascript变量保存为客户端PC上的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会后我的code在编辑......我无法提交我的问题与code包括在内。

I will post my code in an edit... I'm having trouble submitting my question with the code included.

我坚持这是已经建成的时候我被分配给它的聊天程序。我的工作开始时只是更换主题皮肤它,使之我们网站的其他部分相匹配。现在管理要求额外的功能,是在我头上。其中一个特点是一个选项,客户对聊天记录的副本保存到自己的电脑。

I maintain a chat program which was already built when I was assigned to it. My job started out just themeing it to make it match the rest of our website. Now management is asking for additional features that are over my head. One such feature is an option the customer to save a copy of the chat log to their computer.

整个聊天对话被存储在称为chat​​HistoryHTML javascript变量和一个回路使聊天会话在页面上的每5秒钟加入文字新线到chatHistoryHTML变量和历史股利,用于显示其更新顾客看。

The entire chat conversation is stored in a javascript variable called chatHistoryHTML and a loop causes the chat session on the page to update every 5 seconds by adding new lines of text to the chatHistoryHTML variable and displaying it in the 'history' div for the customer to see.

现在,我知道如何打开一个新窗口显示的的聊天记录,并没有任何的标志,背景或文本输入框。不过,我无法通过使用我的方法的PHP命令到新的一页。

Right now, I understand how to open a new window to display only the chat history and none of the logos, backgrounds, or the text input box. However, I'm unable to pass PHP commands to that new page using my method.

在理想情况下,我想一个解决方案,将允许用户点击一个按钮,有一个保存对话框上来,只有保存聊天对话,而无需打开一个新的窗口。我打开一个新窗口,因为现在我试图避免保存所有网页上的其他内容。

Ideally I would like a solution that would allow the user to click a button and have a save dialog come up that only saves the chat conversation, without opening a new window. I'm opening a new window right now because I'm trying to avoid saving all the other content on the page.

我很开放的建议。我知道一些JavaScript和PHP,但一无所知AJAX

I'm open to suggestions. I know a little Javascript and PHP but know nothing about AJAX

推荐答案

主要选项:

  • 导出聊天记录到一个新的窗口,调用打印()(隔离日志,并使其可打印否则用户是抓住了页面上的所有UI元素,以及),或
  • 使用AJAX和把它送上,然后它转发到电子邮件返回给用户的服务器。
  • Dump the chat log to a new window and call print() (isolate the log and make it printable otherwise the user is grabbing all UI elements on the page as well), or
  • Use AJAX and send it off to the server which then relays it to an email back to the user.

JavaScript没有在本地保存文件到客户端的能力。但是,你有一个第二选择:

JavaScript doesn't have the ability to save files locally to the client. However, you have a secondary option:

  • 迁移到Silverlight的/ Flash中有附加功能/特性。

这篇关于如何使用Javascript变量保存为客户端PC上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆