嵌入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);
}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM