如何创建跨平台的Internet快捷方式文件

And*_*een 25 shortcuts

有没有办法创建适用于所有操作系统(包括 Mac、Windows 和 Linux)的 Internet 快捷方式文件?我经常在 Windows 和 Linux 之间切换,我还没有找到一种方法来创建与所有操作系统兼容的 Internet 快捷方式文件(在桌面上或在本地文件夹中)。

And*_*een 26

我找到了一个合理的跨平台解决方案。这个 HTML 文档可以用作 stackoverflow.com 的快捷方式,当从桌面打开时,它会立即重定向到该站点:

<html>
<body>
<script type="text/javascript">
    window.location.href = "http://stackoverflow.com"; //change this to the URL
                                                       //you want to redirect to
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

  • 为什么不在 `&lt;head&gt;` 中使用 `&lt;meta http-equiv="refresh" content="0; url=http://example.com/"&gt;` 而不是依赖 javascript? (23认同)

小智 18

从评论中感谢 Evan Mattson。

来自W3C,技术 H76:使用元刷新创建即时客户端重定向

此技术的目标是在客户端启用重定向,而不会混淆用户。重定向最好在服务器端实现(参见SVR1:在服务器端实现自动重定向,而不是在客户端(SERVER)),但作者并不总是可以控制服务器端技术。

来自上面链接的示例:

<html xmlns="http://www.w3.org/1999/xhtml">    
  <head>      
    <title>The Tudors</title>      
    <meta http-equiv="refresh" content="0;URL='http://thetudors.example.com/'" />    
  </head>    
  <body> 
    <p>This page has moved to a <a href="http://thetudors.example.com/">
      theTudors.example.com</a>.</p> 
  </body>  
</html>
Run Code Online (Sandbox Code Playgroud)

基本上,在零秒后(立即)刷新到指定的 URL,在页面内容加载之前,并且没有 JavaScript。


Roy*_*oyi 10

您可以定义一个名为 - 的文件MyInternetShortcut.url

它的内容应该是:

[InternetShortcut]
URL=https://my.amazingsite.com/
Run Code Online (Sandbox Code Playgroud)

这适用于 Windows 和 macOS。