Html 自定义“添加到主屏幕”的图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43467789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Customize icon for "Add to home screen"
提问by garciam202
Are there any alternatives to the default option in web browsers, like chrome that allows me to add a link or button in my webapp and create an icon in homescreen?
Web 浏览器中的默认选项是否有任何替代方案,例如允许我在 Web 应用程序中添加链接或按钮并在主屏幕中创建图标的 chrome?
For example, I have my webapp and i want a link or button in the main.html that execute an script and create the icon in the homescreen. It is not possible i think. So are there any alternatives that simulate this default option in web browsers?
例如,我有我的 web 应用程序,我想在 main.html 中有一个链接或按钮来执行脚本并在主屏幕中创建图标。我认为这是不可能的。那么是否有任何替代方法可以在 Web 浏览器中模拟此默认选项?
Also i want to specify the icon that shows in the homescreen. How can i do that?
另外我想指定显示在主屏幕中的图标。我怎样才能做到这一点?
回答by shaochuancs
I want to specify the icon that shows in the home screen. How can i do that?
我想指定显示在主屏幕中的图标。我怎样才能做到这一点?
You can use <link rel="apple-touch-icon" sizes="128x128" href="niceicon.png">
(yes, even for Android device).
您可以使用<link rel="apple-touch-icon" sizes="128x128" href="niceicon.png">
(是的,甚至适用于 Android 设备)。
Please check iOS documentfor detail information on Apple devices. Please note you can even define icon for the entire website.
有关 Apple 设备的详细信息,请查看iOS 文档。请注意,您甚至可以为整个网站定义图标。
Please check Android documentfor detail information on Android devices. If <link rel="apple-touch-icon" sizes="128x128" href="niceicon.png">
does not work, you can try <link rel="icon" sizes="192x192" href="nice-highres.png">
, which is the recommended method in Android.
有关 Android 设备的详细信息,请查看Android 文档。如果<link rel="apple-touch-icon" sizes="128x128" href="niceicon.png">
不行,你可以试试<link rel="icon" sizes="192x192" href="nice-highres.png">
,这是Android中推荐的方法。
Are there any alternatives that simulate this default option in web browsers?
是否有任何替代方法可以在 Web 浏览器中模拟此默认选项?
You can check http://cubiq.org/add-to-home-screenfor an alternative. "add-to-home-screen" will show an overlaying message encouraging user to add the web app to the homescreen.
您可以查看http://cubiq.org/add-to-home-screen以获取替代方案。“add-to-home-screen”将显示一条叠加消息,鼓励用户将 Web 应用程序添加到主屏幕。
Note: Thanks to adam0404's comment, cubiq.org link is broken now. Fortunately, the "add-to-home-screen" library was uploaded to GitHub, please check https://github.com/cubiq/add-to-homescreen
注意:感谢adam0404 的评论,cubiq.org 链接现已失效。幸运的是,“add-to-home-screen”库已上传到GitHub,请查看https://github.com/cubiq/add-to-homescreen