如何使iPhone/iPad Web应用保持全屏模式? [英] How do you keep an iPhone/iPad web app in full screen mode?

查看:367
本文介绍了如何使iPhone/iPad Web应用保持全屏模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脱机工作的HTML5 iPad应用.该应用程序基本上由4个html文件和3个aspx文件组成.我的缓存清单已设置,因此只有html文件可脱机使用,而aspx文件需要网络连接.一切都很好!

I have an HTML5 iPad app that works offline. The app essentially consists of 4 html files and 3 aspx files. My cache manifest is setup so that only the html files are available offline, and the aspx files require a network connection. This is all working great!

现在,我已经完成了对应用程序的点睛之笔,并试图最终确定主屏幕图标,以全屏模式运行等.我添加了我认为有必要的内容元标记,使应用程序一旦添加到主屏幕后,便会首先以全屏模式启动.我认为标签正确的原因是,如果我在html页面之间来回导航,该应用程序将(正确)启动并保持全屏模式.我遇到的问题是,当单击服务器(aspx)链接之一时,应用程序将保持全屏模式.

Now, I've gotten to the point where I'm putting the finishing touches on the app and trying to finalize the home screen icons, running in full screen mode, etc. I've added what I believe are the necessary meta tags to make the app initially launch in full screen mode once it's been added to the home screen. The reason I believe the tags are correct is that the app will (correctly) launch and stay in full screen mode if I navigate back and forth between the html pages. The problem I'm having is getting the app to stay in full screen mode when one of the server (aspx) links are clicked.

单击服务器链接(aspx)后,Mobile Safari会跳到完整的浏览器模式并打开一个新窗口.这种行为是不可接受的,我希望这里缺少一些简单的东西.

When a server link (aspx) is clicked Mobile Safari kicks out into full browser mode and opens a new window. This behavior is not acceptable and I'm hoping that I'm missing something simple here.

以下是我在所有页面(html + aspx)上使用的元标记:

Here are the meta tags I'm using on all of my pages (html + aspx):

  <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />

希望这提供了理解问题所需的所有必要信息.我在这里看到了其他链接,这些链接表明除主页上标记为书签的页面之外的任何页面都会导致某些人退出全屏模式.这不是我遇到的问题,所以我想开始一个新的讨论.再次,我觉得如果我在应用程序中还有5个以上的html页面,它将继续保持全屏模式.在我的情况下,aspx页面是个问题.

Hopefully this provides all of the necessary information needed to understand the problem. I have seen other links on here stating that ANY page other than the one bookmarked on the home page causes some folks to exit full screen mode. This is not the problem I'm having, so I wanted to start a new discussion. Again, I feel that if I had 5 more html pages in the app it would continue to stay in full screen mode. The aspx pages are the problem in my situation.

推荐答案

让计算机完成繁琐的工作,这就是它们的用途.

Let the computer do the tedious job, that's what they're made for.

这是一段JavaScript代码,我用它来避免重写所有链接.这样,只有那些具有显式target = "_blank"属性的链接才会在Safari中打开.所有其他链接将保留在Web应用程序内.

This is a piece of javascript code I use to avoid rewriting all my links. With that, only those links that have an explicit target = "_blank" attribute will open in Safari. All other links will remain inside the web app.

var a=document.getElementsByTagName("a");
for(var i=0;i<a.length;i++) {
    if(!a[i].onclick && a[i].getAttribute("target") != "_blank") {
        a[i].onclick=function() {
                window.location=this.getAttribute("href");
                return false; 
        }
    }
}

这篇关于如何使iPhone/iPad Web应用保持全屏模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆