去掉wap端手機(jī)瀏覽器頭部搜索欄和底部工具欄的方法:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="x-dns-prefetch-control" content="on" />
<meta name="viewport" content="width=320.1,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui" />
<meta name="apple-mobile-web-app-title" content="yeziyuan" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta content="telephone=no" name="format-detection" />
<meta name="full-screen" content="yes" />
<meta name="x5-fullscreen" content="true" />
<!--蘋果Safari、QQ瀏覽器、UC瀏覽器:-->
<!--刪除蘋果默認(rèn)的工具欄和菜單欄 -->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!--QQ強(qiáng)制全屏-->
<meta name="x5-fullscreen" content="true">
<!--UC強(qiáng)制全屏-->
<meta name="fullscreen" content="yes">
移動(dòng)web前端開發(fā),隱藏瀏覽器地址欄(全屏)解決方案
核心代碼:window.scrollTo(0, 1);
要注意的幾個(gè)點(diǎn):這個(gè)方法要在內(nèi)容加載完成后執(zhí)行,換句話瀏覽器內(nèi)容的高度要超過瀏覽器窗口高度(出現(xiàn)‘滾動(dòng)條’)才有效。針對(duì)高度自適應(yīng)的窗口(height:100%),得用特殊方式解決。
//強(qiáng)制讓內(nèi)容超過
$('#main').css("height",window.innerHeight+100);
window.scrollTo(0, 1);
//重置成新高度
$("#main").css("height",window.innerHeight);
//非常重要,用于兼容不同機(jī)型,防止瀏覽器窗口移動(dòng)
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
另外說明,最后一行,用于阻止瀏覽器默認(rèn)動(dòng)作的手指滑動(dòng)滾動(dòng)頁面。