我是相对较新的网页开发,我被要求添加一个弹出消息,建议用户添加网站快捷方式到他/她的移动主屏幕。
我已经在运行弹出窗口了,但是我的老板要求我检测一下用户是否从快捷方式启动网站,以避免再次显示弹出窗口,我不确定这是否可能。
如有任何帮助或建议,将不胜感激。
if (navigator.userAgent.match(/Android|webOS|BlackBerry|IEMobile|Opera Mini/i)) {
$.fancybox({
'width': '50%', //Use percentage to maintain responsiveness
'height': '50%',
'autoScale': true,
'autoDimensions': false,
'transitionIn': 'fade',
'transitionOut': 'fade',
'centerOnScroll': true,
'type': 'inline',
'href': '#mob_popup',
padding: 8,
helpers: {
overlay: {
css: {
'background': 'rgba(255, 255, 255, 0.45)'
}
}
}
});发布于 2014-02-11 16:41:23
使用javascript检查window.navigator.standalone属性。如果您是从主屏幕启动的,则该属性将出现在true中,如果您在Safari (或其他浏览器),则该属性将是false。
发布于 2022-03-18 03:21:19
window.navigator.standalone === truewindow.matchMedia('(display-mode: standalone)').matches参考见similar post。
https://stackoverflow.com/questions/21707511
复制相似问题