使用网页创建桌面快捷方式
我正在尝试在网页上创建一些内容,允许我的用户创建桌面快捷方式。因为我的用户不懂技术,所以我想避免让他们尝试拖放。
有没有一种方法可以在网页上创建一个按钮(使用 JavaScript 或 .Net),自动为用户创建桌面快捷方式?¡
I am trying to create something on a webpage that allows my users to create a desktop shortcut. Because my users are NOT technically savvy, I would like to avoid having them try to drag and drop.
Is there a way that I could create a button on a webpage (either using JavaScript or .Net) that automatically creates a desktop shortcut for the user?¡
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简单方法:使用浏览器提供的功能
在 Firefox 中,拖动并单击删除桌面链接会在 Windows 7 中创建快捷方式。我确信所有或大多数主要浏览器都可以在大多数平台上执行此操作。只需为您的用户指明正确的方向,也许可以为他们提供自定义的分步说明。
您可以将链接设计为易于识别、拖放的大区域。它不需要只是一段带下划线的文本。
在我看来,这是唯一值得走的路。
困难的方法:自己编程
我不认为使用 JavaScript 可以完成创建桌面链接 - 会有太多的安全限制阻止它。
对于 Windows,我认为最接近的事情是在服务器端生成快捷方式
.lnk
文件,并提供这些文件供下载。但它并不是微不足道的,而且 Microsoft 也没有记录其结构。有这样的非官方指南:Windows 快捷方式文件格式您可能是能够通过在本地系统上创建文件并提供下载来避免生成文件。如果您使用绝对网址,它可能会起作用 - 您必须尝试一下。不要忘记在各种系统上进行测试:95、98、XP、Vista、7 ....
我确信 Mac OS 和各种 Linux 桌面上有等效的快捷方式格式,但我不知道它们。
Easy way: Using what the browsers offer
In Firefox, dragging & dropping a link to the desktop creates a shortcut in Windows 7. I'm sure all or most major browsers can do this on most platforms. Just point your users to the right direction, maybe by offering them custom step-by-step instructions.
You can style the link as a huge area easy to recognize, drag and drop. No need for it to be just an underlined piece of text.
This is, in my opinion, the only worthwhile way to go.
Hard way: Programming it yourself
I don't think creating a desktop link can be done using JavaScript - there will be too many security restrictions in place blocking it.
For Windows, I think the closest thing would be generating shortcut
.lnk
files on server side, and offering those for download. It's not trivial though, and its structure is not documented by Microsoft. There are unofficial guides like this: The Windows Shortcut File FormatYou may be able to get around generating the files by creating them on your local system, and offering them for download. It may work if you use absolute web addresses - you'd have to try out. Don't forget to test on the various systems: 95, 98, XP, Vista, 7 ....
I'm sure there are equivalent shortcut formats on Mac OS and the various Linux Desktops, but I don't know them.
不,不要求您的用户具有足够的技术头脑才能为嵌入在页面上的脚本或组件提供高级权限。 (当然,这主要意味着说“是”,但会出现一个看起来吓人的提示。如果他们收到关于该主题的任何建议,他们会说“不”。)
你可以这样做使用签名的 Java 小程序等(这个问题与此讨论相关;基本上你想在他们的系统上创建一个文件),但是你的用户允许他们以高权限运行的可能性较低(我会'已经说过)比他们能够处理拖放。
我不认为我曾经认为拖放是一种技术娴熟的操作。 :-)
No, not without requiring your users to be sufficiently technically-savvy to give a script or component embedded on the page advanced permissions. (Granted this mostly means saying "Yes," but to a scary-looking prompt. If they've received any advice on the subject, they're going to say "no.")
You can do this with signed Java applets and the like (this question relates to this discussion; basically you want to create a file on their system), but the odds of your users allowing them to run with high privilege are lower (I'd've said) than their being able to handle drag and drop.
I don't think I've ever thought of drag and drop as being a technically-savvy operation. :-)
我发现这个花絮适用于 Edge 和 FireFox - 不适用于 Chrome,也不了解 Apple 设备:
Javascript - 以编程方式创建桌面链接
我假设您和我一样正在尝试使网站用户可以轻松地将快捷方式下载到桌面。到目前为止,这就是我在台式电脑上找到的所有内容 - PWA 允许我的 Android 自动添加主屏幕快捷方式 - 但 iPhone 却不行。
I found this tidbit works in Edge and FireFox - not Chrome and don't know about Apple devices:
Javascript - create desktop link programmatically
I'm assuming you, like I am, are trying to make it easy for website users to download a shortcut to their desktop. So far this is all I've found for desktop computers - a PWA allows my Android to automatically add a shortcut to the home screen - not iPhone, however.