嵌入app中H5页面title值的修改

安卓下,用document.title能够很好地设置app中页面的title值,可是ios下没有效果,因此如下这段代码主要是解决ios下设置title的问题javascript

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);
}
}
相关文章
相关标签/搜索