开发者

Creating a Desktop Shortcut Using a Web Page

开发者 https://www.devze.com 2022-12-22 20:48 出处:网络
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 dr

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?¡


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消