windowIssue.js //-------------------------------开发中遇到的window问题汇总---------------------------------// //1.解决浏览器的白色背景//如果是游戏客户端中嵌套网页,可以使用此方法来处理页面白屏问
//-------------------------------开发中遇到的window问题汇总---------------------------------//
//1.解决浏览器的白色背景
//如果是游戏客户端中嵌套网页,可以使用此方法来处理页面白屏问题
//总结:白屏的出现是因为在页面没有加载完毕的时候,webview以及存在
//这期间页面有一个空白期,所以要在页面加载完毕的时候,给客户端传递一个参数让其开启webview,
function native_call(url) {
url = 'native://?action=' + encodeURIComponent(url);
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", url);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
}
window.onload=function(){
native_call('onDidFinished')
}
//解决技巧与客户端约定好时间,显示webview
//如果与rem布局配合使用
//rem布局调用函数
utils.htmlSetFontSize()
//通知客户端显示webview
window.onload = function () {
let url = 'native://?action=' + encodeURIComponent('onDidFinished');
utils.native_call(url)
};
//2.去掉弹框上面的网址内容
//此方法在手机上只会显示弹框的内容,不会显示弹框上的地址信息
window.alert = function(name){
var iframe = document.createElement("IFRAME");
iframe.style.display="none";
iframe.setAttribute("src", 'data:text/plain,');
document.documentElement.appendChild(iframe);
window.frames[0].window.alert(name);
iframe.parentNode.removeChild(iframe);
};
//解决方法:页面显示为嵌入式显示
