1
2

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.

JavaScriptでapple-touch-iconを設定

Posted at

JavaScriptでapple-touch-iconを設定

ものすごーく小ネタです。

iPhoneやiPadなどのWebクリップ用のアイコン設定ですが、いちいち全ページに追記するのは面倒ですよね。
機種や解像度で設定が増えたりしますし。
…ということで、もともと全ページに埋め込んでる共通のJavaScriptで設定タグを埋め込むようにします。

ちなみにアップルのガイドラインはこちらです。
Specifying a Webpage Icon for Web Clip

まぁHeadにLinkタグを挿入するだけなんですが。

JavaScipt
//apple-touch-icon対応
var icon = document.createElement("link");
icon.setAttribute("rel","apple-touch-icon");
icon.setAttribute("href","/apple-touch-icon.png");
document.head.appendChild(icon);

種類が増えた場合はループなりで対応します。

お粗末...

1
2
0

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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?