嵌入app中H5页面title值的修改
安卓下,用document.title可以很好地设置app中页面的title值,但是ios下没有效果,所以以下这段代码主要是解决ios下设置title的问题
var userAgent = navigator.userAgent;
var cookiestr = document.cookie;
if (userAgent.indexOf('cdvsupport') >= 0 || cookiestr.indexOf('cdvsupport') >= 0) {
//alert('nativejs')
document.write("<script type='text/javascript' src='nacodovafile/js/cdplugins.js#nacodovafile'><\/script>");
document.write("<script type='text/javascript' src='nacodovafile/js/cordova.js#nacodovafile'><\/script>");
}
function deviceReadyOne(cb_back){
var deviceReady = function(){
document.removeEventListener("deviceready", deviceReady, false);
if('function' == typeof cb_back){
cb_back();
}
}
document.addEventListener("deviceready", deviceReady, false);
}
// export default {
function setPageTitle(title) {
document.title = title;
var callback = function(){
try{
window.CD58UtilsPlugin.setTitle(title);
}catch(e){}
}
if (window.CD58UtilsPlugin) {
callback();
} else {
deviceReadyOne(callback);
}
}