ios免签封装去网址,隐藏状态栏,不显示顶部网址
温馨提示:文章已超过208天没有更新,若内容或图片失效,请留言反馈!
由于IOS封装原生ipa文件需要企业签名,基本上都是忽悠。因为共享的几天就掉,独享的又贵,TF更是贵得惊人,所以就有了ios免签一说。
网站封装会出现3个坑,前面2个坑教程很多,今天主要解决大坑,全网搜不到被某宝某多几十几百坑钱的,到底怎么去掉这个封装后显示的网址问题。
3个问题如下:
问题一:顶部始终会出现不安全提示
这是最好解决的问题,那就是直接给网站配置https,也就是配置下ssl证书,宝塔环境最简单。
问题二:普通的网页情况下,点击任何链接都会跳出到浏览器
这个问题的解决方法很多这个简单点,是在网页的头部head或者通用的某个页面区块或者通用js中,加入如下代码:
<script type="text/javascript"> if(("standalone" in window.navigator) && window.navigator.standalone){ var noddy, remotes = false; document.addEventListener('click', function(event) { noddy = event.target; while(noddy.nodeName !== "A" && noddy.nodeName !== "HTML") { noddy = noddy.parentNode; } if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 || remotes)) { event.preventDefault(); document.location.href = noddy.href; } },false); } </script>
上面这段js的原理是,识别到ios设备浏览,并将所有的可跳转a标签,都变为js动态跳转形式,这样就可以防止跳出到浏览器。但是还会存在第三个问题,那就是点击任何链接,跳出的页面都会带一个有网址的头部,非常影响界面效果和体验感觉像假的。
问题三:点击链接会跳出带网址的头部,使用起来不像app
在网站的根目录(其它目录也可以),新建一个html后缀的文件,将以下的代码放进去,网站地址指向这个文件就行了。
<html style="font-size: 96px;"> <head> <meta http-equiv="Content-Type" content="text/html;" > <meta http-equiv=" x-ua-compatible"=""> <script> document.addEventListener('DOMContentLoaded', function() { document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px' }) var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)')) document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"> </head> <body scroll="no"> <style mce_bogus="1"> body { margin: 0px; } iframe {border: 0px;} </style> <iframe id="frame3d" name="frame3d" frameborder="0" width="100%" scrolling="auto" style="margin-top: -4px;" οnlοad="this.style.height=document.body.clientHeight-84" height="100%" src="你的网址" mce_src="你的网址"></iframe> </body> </html>
这段代码的原理就是,用iframe嵌套的原理包裹整个网站,所以里面的网站无论怎么点击,都没有出现页面地址的变更,于是就不会出现头部网址了。