用于在随身碟中分发的离线网络应用程序(仅限 Windows)?

发布于 2024-12-10 11:38:33 字数 1228 浏览 0 评论 0原文

我们正在尝试分发一个基本的 HTML 文件,其中包含一些指向 USB 驱动器中的 PDF 文档的链接,用于广告目的。这个想法是自动运行在默认浏览器中打开此 HTML。然而,这可能不是一个好主意,因为它看起来非常业余,而且我们将不得不依赖默认浏览器的技术(不幸的是,它很有可能是 IE6/7!)

我们已经探索了一些替代方案,但我们找不到真正适合我们想要实现的目标:

  1. Mozilla棱镜
    尽管它的设计似乎考虑了离线 Web 应用程序,但可执行文件会在用户的 AppData 目录中创建文件,并且很难配置默认路径。另外,Firefox 没有默认的 PDF 查看器,因此我们必须依赖用户的默认 PDF 查看器(可能是 Adob​​e Reader)
  2. Mozilla Chromeless
    由于 Prism 处于非活动状态,这个想法仍在使用 Chromeless 进行开发,它允许开发人员使用基本的 HTML/JS/CSS 创建浏览器界面。这里的主要问题是,不知何故,构建没有加载 HTML,所有显示的都是 灰色 iframe。我不确定是否只有我一个人这样,因为问题页面上没有任何内容。
  3. 便携式应用程序
    我们可以引入 Firefox 或 Chrome 的便携版本,并为 Firefox 或 自定义 XUL在应用模式下打开 Chrome

Firefox 的优势在于它支持相对路径 (resource://),但它没有内置的 PDF 查看器。 Chrome 有一个非常好的轻量级 PDF 查看器,内置应用程序模式对我们来说是一个非常有用的功能,但我找不到如何在没有通常的绝对路径的情况下打开本地路径(file:/// C:/),因为我们不知道驱动器的盘符是什么。

有谁知道如何处理此类问题?谢谢。

We are trying to distribute a basic HTML file with some links to a PDF document in a USB drive for advertising purposes. The idea is that an autorun opens up this HTML in the default browser. However, this might not be a good idea since it would look very amateur-ish and we will have to rely on the default browser's technology (which unfortunately has a good chance on being IE6/7!)

We've explored a few alternatives, but we can't find one that really fits what we are trying to achieve:

  1. Mozilla Prism
    Altough it seems like it's designed with offline web apps in mind, the executable creates files in the user's AppData directory and it's hard to configure the default paths. Also, Firefox doesn't have a default PDF viewer, so we will have to depend on the user's default PDF viewer (which might be Adobe Reader)
  2. Mozilla Chromeless
    Since Prism is inactive, the idea is still developing with Chromeless, which allows the developer to create the browser interface with basic HTML/JS/CSS. The main issue here is that somehow the build isn't loading HTML, all that's showing is a gray iframe. I'm not sure if it's just me, because there's nothing on the issues page.
  3. Portable App
    We could throw in the portable version of Firefox or Chrome and customize the XUL for Firefox or open Chrome in app mode.

Firefox's advantage is that it kind of supports relative paths (resource://), but it doesn't have a built-in PDF viewer. Chrome has a very good and lightweight PDF viewer and the built-in app mode is a very useful feature for us, but I can't find how to open a local path without the usual absolute path (file:///C:/) since we don't know what's the drive's letter.

Has anyone figure out how to handle this kind of issues? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

游魂 2024-12-17 11:38:33

三年前就有人问过这个问题,但尚未得到解答,在 Google 中排名很高,我偶然发现了完全相同的问题,并且可以想象许多其他寻求发布可在本地运行且具有最少依赖项的便携式 Web 应用程序的人将也遇到这个问题。

我现在使用的解决方案是node-webkit。

您可以将其视为 chrome 的便携式版本,但是它除了应用程序入口点的相对路径之外,大约小 40 MB,并且比 chrome 的 --app 模式更可自定义(如果是,则根本无法自定义)我没记错)。

Github 和下载:
https://github.com/rogerwang/node-webkit#downloads

详细指南:
http://thejackalofjavascript.com/getting-started-with-node-webkit- apps/

我对 Windows 的使用建议:

  1. 首先按照上面链接的指南中的说明创建一个应用程序包
  2. 为了让 node-wekit 与您的应用程序一起加载,您需要像这样启动它:

    nw.exe app.package

其中 nw.exe 位于压缩文件夹的根目录中您下载的 app.package 是一个 zip 文件(可以具有任何名称),其中包含您的应用程序数据和 package.json。

要静默执行此操作,您可以使用包含上面(修改后的)调用的 BAT 文件和包含以下内容的 VBS 文件:

CreateObject("Wscript.Shell").Run "cmd /c launchNW.bat", 0, true

launchNW.bat 是 BAT 文件的名称。现在运行VBS文件;应该会弹出一个包含您的网络应用程序的窗口,而不会同时出现命令窗口。

  1. 阅读完链接指南,了解有关隐藏浏览器 UI 等操作的自定义选项的更多信息。

This has been asked three years ago, but it's unanswered, listed high in Google, and I stumbled over the exact same problem and can imagine that many others that seek to ship portable web apps that can be run locally and with a minimum of dependencies will encounter this issue, too.

The solution I am now going with is the node-webkit.

You can treat it like a portable version of chrome, however it excepts a relative path to your app's entry point, is about 40 MB smaller, and much more customizable than the --app mode of chrome (which isn't customizable at all if I remember correctly).

Github & Download:
https://github.com/rogerwang/node-webkit#downloads

An extensive guide:
http://thejackalofjavascript.com/getting-started-with-node-webkit-apps/

My usage suggestion for Windows:

  1. First create an app package as explained in the guide linked above
  2. For the node-wekit to load with your app, you need to start it like this:

    nw.exe app.package

Where nw.exe is in the root of the zipped folder you downloaded and app.package is a zip file (can have any name) that contains your app data and package.json.

To do this silently, you can use a BAT file containing the (amended) call above and a VBS file containing something like this:

CreateObject("Wscript.Shell").Run "cmd /c launchNW.bat", 0, true

launchNW.bat being the name of your BAT file. Now run the VBS file; a window containing your web app should pop up without the command window appearing with it.

  1. Finish reading the linked guide to learn more about customization options to do things like hiding the browser UI etc.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文