Creating a Desktop Shortcut Using a Web Page

故事扮演 提交于 2019-11-29 10:58:14

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 Format

You 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.

T.J. Crowder

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. :-)

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!