简体   繁体   English

简单,独立(即没有外部文件),基于客户端的脱机离线解决方案,用于使用Javascript选择文件并显示HTML内容

[英]Simple, standalone (i.e., no external files), offline, client-based solution for selecting file and displaying contents in HTML with Javascript

I'd sum this up as looking for an offline client solution that is 100% standalone and uses no external files/libraries or other machine resources to tabulate data from a user-chosen TSV file (the result is simply rendered in a plain HTML table - nothing fancy, just data). 我将其总结为寻找一种脱机客户端解决方案,该解决方案是100%独立的,并且不使用外部文件/库或其他机器资源来制表用户选择的TSV文件中的数据(结果只是在纯HTML表中呈现) -没有幻想,只有数据)。

I am not a web programmer, but have volunteered to do this project. 我不是网络程序员,但是自愿参加了这个项目。 I have been asked to code this as a browser-based solution because the party deems it the most user-friendly for their needs. 我被要求将此代码编码为基于浏览器的解决方案,因为该方认为它对他们的需求最为用户友好。

Again, this is not an html file that is served; 同样,这不是提供的html文件; it is emailed to a client that copies it into a folder of their choosing and run (by selecting a local file to render). 它将通过电子邮件发送给客户端,客户端将其复制到他们选择的文件夹中并运行(通过选择要渲染的本地文件)。

Every time I attempt some solution (eg, FileReader, etc.), I can only get it to only work in a certain manner with specific browsers (including having to use it differently in the same code depending upon the browser - is this simply my lack of knowledge?). 每当我尝试某种解决方案(例如FileReader等)时,我只能使它只能以特定的方式在特定的浏览器上工作(包括必须根据浏览器在同一代码中以不同的方式使用它-这仅仅是我的意思)缺少知识?)。

My question is: Is there one single way to code this for most browsers (including older browsers like IE8)? 我的问题是:对于大多数浏览器(包括IE8等较旧的浏览器),是否只有一种方法可以编写此代码?

If not, I would most appreciate suggestions - both general and specific. 如果没有,我将不胜感激建议-一般性和具体性。 An example would be helpful if possible. 如果可能的话,一个例子会有所帮助。 Thank you in advance. 先感谢您。

If you're looking for client/browser specific, you won't have access to the file system. 如果您要查找特定于客户端/浏览器的文件,则将无权访问文件系统。 That's a security breach that isn't implemented into the browsers. 这是未在浏览器中实现的安全漏洞。 You're going to need to implement some sort of server-side technology to take a crack at the file being handed over, or you will need to strictly specify which browsers are supported (things like FileReader are only IE10 or better). 您将需要实施某种服务器端技术来破解要移交的文件,或者您需要严格指定受支持的浏览器(诸如FileReader之类的产品仅是IE10或更高版本)。

I've never tried using the INPUT FILE to see if it will load a file before pushing it to the server (in say a FORM POST or a XHR/AJAX push)- but maybe look here: 我从来没有尝试过使用INPUT FILE来查看它是否会在将文件推送到服务器之前(例如FORM POST或XHR / AJAX推送)加载文件,但是也许可以在这里查看:

https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications https://developer.mozilla.org/zh-CN/docs/Using_files_from_web_applications

Let's see -- what else. 让我们看看-还有什么。 If the file has a specific name, your HTML could reference it in an IFRAME and see if you can't communicate back and forth between the IFRAME and the parent window. 如果文件具有特定名称,则您的HTML可以在IFRAME中引用该文件,并查看您是否无法在IFRAME与父窗口之间来回通信。

You're really limiting yourself without having a server being able to process it, and the browser range you need. 您实际上是在限制自己,而没有服务器能够处理它以及所需的浏览器范围。 Your best bet might be the File API and restrict the lower limit of browser compatibility? 您最好的选择可能是File API,并限制浏览器兼容性的下限?

http://www.html5rocks.com/en/tutorials/file/dndfiles/ http://www.html5rocks.com/zh-CN/tutorials/file/dndfiles/

AFAIK, there is no way to do this for all browsers. AFAIK,无法对所有浏览器执行此操作。 Especially for IE8. 特别是对于IE8。 If you need a standalone application, the best way is to use C++/Java/C# or any language that allows to create desctop applications. 如果需要独立的应用程序,最好的方法是使用C ++ / Java / C#或允许创建桌面应用程序的任何语言。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我应该如何在流星项目中加载外部文件(即js,css,html)? - How should i load external files(i.e. js,css,html) in meteor project? Javascript - IE、Chrome、Firefox - 包含 external.js 文件的工作原理? - Javascript - I.E., Chrome, Firefox - How inclusion of external .js files works? VSCode:获取用于运行独立脚本的启动配置(即 JavaScript 和 Node.js) - VSCode: getting which launch configuration was used to run a standalone script (i.e. JavaScript with Node.js) 如何将React JSX文件转换为简单的JavaScript文件[离线转换] - How to convert react JSX files to simple JavaScript file [offline transformation] 如何在没有webserver-stuff(即AJAX)的情况下获取外部JavaScript的文本 - How to get the text of a external JavaScript without webserver-stuff (i.e. AJAX) 如何将 JSON 数组从服务器发送到客户端,即(java 到 AJAX/Javascript)? - How to send JSON array from server to client, i.e. (java to AJAX/Javascript)? JavaScript提示输入密码(即*******) - javascript prompt for password (i.e. *******) 使用客户端技术(即Javascript)仅显示表的一部分 - Showing only part of a table using Client-side technologies, i.e. Javascript 在客户端(即在 javascript 中)检查 firebase db ref 的正确方法是什么? - What is the correct way to check firebase db ref on client side(i.e. in javascript)? javascript在IE 9和Firefox中均不起作用 - javascript not working in I.E. 9 as well as Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM