Why won't this apple-touch-icon work?

允我心安 提交于 2019-12-19 19:41:21

问题


I have the following code in my website:

<link rel="apple-touch-icon" href="http://website.com/images/apple-touch-icon.png" />

When I view the source in Firefox and click the href attribute the icon shows (so its not a 404 error).

When the code is added to a page like http://website.com/mobile/index.php or http://website.com/mobile/page.php and the page is added to an iPhone homescreen the icon works fine, but when the page url is like http://website.com/page or http://website.com/index the icon doesn't show up.

No errors appear in the "website debug console" provided in Safari options and I've tried clearing the cache and cookies.

Also I use the tag <base href="http://website.com/mobile/" /> website, which shows up on both http://website.com/mobile/index.php and http://website.com/index. But i can't see how that would effect it since the apple-touch-icon uses a full url.


回答1:


Try using a relative URL:

<link rel="apple-touch-icon" href="/images/apple-touch-icon.png" />

It should go to your base directory and find the icon in /images.




回答2:


This will only work from an HTTP or HTTPS site with a Valid and trusted security certificate.

If there's a certificate error, iOS will not load the image. Temporarily trusting the certificate in Safari for the page will not trust the certificate for the homescreen shortcut. If you are using a self-signed certificate, you must add the untrusted root certificate as a trusted certificate at the OS level.

  1. On the iOS device, navigate to a page which has a link to the .crt file
  2. Tap the link
  3. Approve/Install through all the confirmation screens


来源:https://stackoverflow.com/questions/6807349/why-wont-this-apple-touch-icon-work

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