如何在 jQTouch 应用程序中要求全屏模式?

发布于 2024-08-24 20:20:16 字数 733 浏览 4 评论 0原文

我正在使用 jQTouch 开发一个针对 iphone 上的 safari 进行优化的网站版本。 jQTouch 演示有助于展示如何为不使用全屏模式的用户显示“安装此”消息,并为使用全屏模式的用户隐藏它。当处于全屏模式时,主体应该具有“全屏”类。因此,您可以通过将此 css 规则添加到您的样式表中,为已将您的应用添加到其主页的用户隐藏“安装此”消息:

body.fullscreen #home .info {
    display: none;
}

我想要做的是要求用户使用该应用程序仅在全屏模式下。从常规浏览器查看时,他们应该只会看到一条要求他们安装应用程序的消息。否则该消息当然应该被隐藏。

这应该非常非常容易,所以我一定是错过了一些明显的东西。

我认为做到这一点的一种方法是简单地测试主体上的“全屏”类:如果它不存在,请使用 goTo 到达另一个 div,或隐藏其他 div,或类似的东西。

然而奇怪的是,这不起作用。作为测试,我仍然收到原始的“信息”消息,如 jQTouch 演示中所示,并且当我以全屏模式启动时它不会显示。因此主体必须具有全屏类。但我找不到它的任何其他痕迹:当我在文档加载后放置此警报来测试内容时,在全屏模式下启动时我什么也得不到:

alert($("body").attr("class"));

我还认为我可以通过检查值来测试全屏模式全屏布尔值的。但这似乎也不起作用。我缺少什么?最好的方法是什么?

I'm using jQTouch to develop a version of a website optimized for safari on the iphone. The jQTouch demo helpfully shows how to show an "install this" message for users not using full screen mode and hide it for those who are. When in fullscreen mode, the body should have the class "fullscreen." So you can hide the "install this" message for people who have already added your app to their home page by adding this css rule to your stylesheet:

body.fullscreen #home .info {
    display: none;
}

What I'd like to do is require users to use the app in fullscreen mode only. When viewed from the regular browser, they should only see a message asking them to install the app. That message should of course be hidden otherwise.

This ought to be really, really easy, so I must just be missing something obvious.

I thought one way to do this would be to simply test for the class "fullscreen" on the body: if it's not there, use goTo to get to another div, or hide the other divs, or something like that.

Strangely, however, this doesn't work. As a test, I've still got the original "info" message, as in the jQTouch demo, and it doesn't show up when I launch in fullscreen mode. So the body must have the fullscreen class. And yet I can't find any other trace of it: when I put this alert to test things after the document has loaded, I get nothing when launching in fullscreen mode:

alert($("body").attr("class"));

I also thought I might test for fullscreen mode by checking for the value of the fullScreen boolean. But this doesn't seem to work either. What am I missing? What is the best way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

总攻大人 2024-08-31 20:20:16

好吧,我不明白为什么标准方法不起作用,但 jQTouch Google Group 上的某人建议这样做,它有效:

    if (window.navigator.standalone) {
   alert ('Thanks for launching this app your home screen')
} else {

   alert('Add this app to your home screen for the best experience')

} 

Well, I couldn't figure out why the standard way wasn't working, but someone on the jQTouch Google Group suggested this, which works:

    if (window.navigator.standalone) {
   alert ('Thanks for launching this app your home screen')
} else {

   alert('Add this app to your home screen for the best experience')

} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文