3.16.1、无底部导航的App版禁止外层页面容器出现滚动条影响整个页面效果
一、问题描述:
1、当使用无底部导航栏的App版本时,外层容器的高度与有底部导航的版本不一致,用户使用时会出现2个滚动条;外层滚动条滚动会导致页面变形:
二、问题原因:
1、页面的外层框架容器允许滚动
三:解决办法:
1、禁止外层框架容器滚动,在Pending.html中的InitiateIOSPush函数里面加入以下代码:
//禁止外层框架容器滚动 Script += "try{"; Script += "jQuery(document.body).css('overflow', 'hidden');"; Script += "}catch(e){ }";
参考整个InitiateIOSPush的代码如下:
//初始化IOS端的推送 function InitiateIOSPush() { //receive事件 var Script = ""; //重写框架弹出窗口的函数(MobileDeviceAPI.Webview.PopupNewWindowPage) Script += "try{"; Script += "MobileDeviceAPI.Webview.PopupNewWindowPage = function (Config)"; Script += "{"; Script += "var PopupNewWindowPageInitiateStatusBarBackGroundColor = plus.navigator.getStatusBarBackground();"; Script += "var guid = NewGuid().replace(/\-/ig, \"\");"; Script += "var view = plus.webview.open(\"PopupNewWindowPage.html?title=\" + encodeURIComponent(Config.title) + \"&url=\" + encodeURIComponent(Config.url) + \"&HideHeader=\" + Config.HideHeader + \"&v=\" + Math.random(), guid, {}, 'slide-in-right', 300, function(){ view.evalJS(\" document.getElementById('PageMainContentIFrame').src=''; window.setTimeout(function (){ StartLoadPage(); }, 50); \"); });"; Script += "view.addEventListener('popGesture', function (e)"; Script += "{"; Script += "if (e.type == \"end\")"; Script += "{"; Script += "HideLoadingStatusDIV();"; Script += "if (typeof (PopupNewWindowPageInitiateStatusBarBackGroundColor) != \"undefined\")"; Script += "{"; Script += "plus.navigator.setStatusBarStyle(PopupNewWindowPageInitiateStatusBarBackGroundColor.toLowerCase().indexOf(\"#fff\") >= 0 ? \"dark\" : \"light\");"; Script += "plus.navigator.setStatusBarBackground(PopupNewWindowPageInitiateStatusBarBackGroundColor);"; Script += "}"; Script += "}"; Script += "}, false);"; Script += "return guid;"; Script += "};"; Script += "}catch(e){ alert(e.toString()); }"; //禁止外层框架容器滚动 Script += "try{"; Script += "jQuery(document.body).css('overflow', 'hidden');"; Script += "}catch(e){ }"; //初始化推送 Script += "if (!PageDynamicObject.hasOwnProperty('InitiateIOSPush'))"; Script += "{"; Script += "PageDynamicObject.InitiateIOSPush = true;"; Script += "plus.push.addEventListener(\"receive\", function (msg)"; Script += "{"; Script += "if (msg.payload != \"LocalMSG\")"; Script += "{"; Script += "if (msg.content.indexOf(\":\") > 0)"; Script += "{"; Script += "var contentarray = msg.content.split(\":\");"; Script += "var CurrentPageUniqueKey = contentarray[0];"; Script += "if (!PageDynamicObject.hasOwnProperty('CurrentPageUniqueKey') || PageDynamicObject.CurrentPageUniqueKey != CurrentPageUniqueKey)"; Script += "{"; Script += "plus.push.createMessage(msg.content, 'LocalMSG');"; Script += "}"; Script += "}"; Script += "else"; Script += "{"; Script += "plus.push.createMessage(msg.content, 'LocalMSG');"; Script += "}"; Script += "}"; Script += "}, false);"; Script += "}"; WindowMessageClass.PostMessage("(function(){ " + Script + " })", {}); }