开发者

iPad website fullscreen in Safari

开发者 https://www.devze.com 2023-01-18 19:51 出处:网络
I am trying to get a 开发者_如何学JAVAwebsite that runs fullscreen for all pages, I have looked over here: iPad WebApp Full Screen in Safari and followed that and my index page fills the screen just n

I am trying to get a 开发者_如何学JAVAwebsite that runs fullscreen for all pages, I have looked over here: iPad WebApp Full Screen in Safari and followed that and my index page fills the screen just nicely, but whenever I click a link to another page even though that page is all setup with the meta tags it pulls the chrome bar back in and all the alignment goes out.

There must be a way or is that a limitation of safari that will be fixed in a later revision.


I have written a jQuery plugin for this exact purpose: https://github.com/mrmoses/jQuery.stayInWebApp

Include the plugin somehow , then run it like so:

$(function() {
    $.stayInWebApp();
});

By default it will attach to all <a /> elements. You can pass a different selector to attach it to specific links. For example, $.stayInWebApp('a.stay'); will attach to all links that have class="stay"

Because its so small, I usually just copy the minified version into one of my other external javascript files to include it, rather than having to add another external js reference.

Also available on plugins.jquery.com


You can try something like this:

if ((navigator.userAgent.indexOf('iPad') != -1)) {
    // for standalone (app) fulscreen mode
    if (window.innerHeight == 748 || window.innerHeight == 1004) { 
        var a = document.getElementsByTagName("a");
        for (var i = 0, len = a.length; i < len; i++) {
            if (a[i].getAttribute("href");) {
                a[i].onclick = function() {
                    window.location = this.getAttribute("href");
                    return false;
                }
            }
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消