19
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mac, Linux, Windowsで共通に使える簡易URLショートカットファイル

Last updated at Posted at 2016-01-24

言われてみればなんてことはないが、なぜ今まで知らなかった。

cross-platform-url-shortcut.html
<html>
<body>
<script type="text/javascript">
    window.location.href = "http://stackoverflow.com";
</script>
</body>
</html>

タグとかセミコロンとか諸々をタイプする時間すら惜しいならこちらの省略版。

cross-platform-url-shortcut.html
<!DOCTYPE html>
<script>window.location.href = "http://stackoverflow.com"</script>

ウェブサイトじゃなくてローカルPCのファイルやフォルダへのリンクだったら、IE以外ならこれで大丈夫そう。

cross-platform-file-uri-shortcut.html
<!DOCTYPE html>
<script>
  var osType = navigator.appVersion;
  var userName = 'mmizutani'
  var homePath;
  if (osType.indexOf('Win')!=-1) {
    homePath = 'C:/Users/';
  } else if (osType.indexOf('Mac')!=-1) {
    homePath = '/Users/';
  } else if (osType.indexOf('Linux')!=-1) {
    homePath = '/home/';
  }
  if (homePath) {
    var url = 'file://' + homePath + userName + '/Dropbox/';
    //alert(url);
    window.location.href = url;
  }
</script>
19
17
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?